|null $jobs */ final class NoticeMessage { /** * Array of message data. * * @var array|null> */ private $data = []; /** * Creates a notice message. * * @param string $template Template name without extension. * @param string|null $button_label Optional button label. * @param string|null $button_url Optional button URL. */ public function __construct( string $template, ?string $button_label = null, ?string $button_url = null ) { $template_name = strtolower( $template ); $this->data['template'] = sprintf( '/notice/%s.php', $template_name ); $this->data['button_label'] = $button_label; $this->data['button_url'] = $button_url; } /** * Get a message variable. * * @param string $name The variable name. * * @return string|array|null */ public function __get( $name ) { if ( ! isset( $this->data[ $name ] ) ) { return null; } return $this->data[ $name ]; } /** * Sets a variable for the message. * * @param string $name The variable to set. * @param string|array $value The value to set. */ public function __set( $name, $value ): void { $this->data[ $name ] = $value; } /** * Check if variable is set. * * @param string $name The variable to check. */ public function __isset( $name ) { return isset( $this->data[ $name ] ); } }