controller = $controller; } /** * Add a notice to the stack. * * @param Notice $notice * * @return self */ public function add( Notice $notice ): self { $this->notices[] = $notice; return $this; } /** * Display all notices in the stack. */ public function display(): void { if ( count( $this->notices ) <= 0 ) { return; } foreach ( $this->notices as $notice ) { $this->controller->render( $notice->toArray() ); } } /** * Get all the notices. * * @return Notice[] */ public function all(): array { return $this->notices; } /** * Clear all notices in the stack. */ public function clear(): self { $this->notices = []; return $this; } }