HEX
Server: Apache
System: Linux flamboyant-gauss.194-164-62-186.plesk.page 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: gamesamphora (10001)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/amphoragames.com/httpdocs/wp-content/plugins/backwpup/inc/Notice/NoticeMessage.php
<?php

namespace Inpsyde\BackWPup\Notice;

/**
 * Class NoticeMessage
 *
 * Handles the creation and management of notice messages within the BackWPup Pro plugin.
 * This class is responsible for displaying, storing, and formatting admin notices
 * to inform users about important events or actions required.
 * This class is marked as final and cannot be extended.
 *
 * @package BackWPupPro\Notice
 *
 * @property string $id
 * @property string|null $buttonLabel
 * @property string|null $buttonUrl
 * @property string|null $dismissActionUrl
 * @property string|null $type
 * @property string                  $template
 * @property array<int, string>|null $jobs
 */
final class NoticeMessage
{
    /**
     * Array of message data.
     *
     * @var array<string, string|array<int, string>|null>
     */
    private $data = [];

    public function __construct(string $template, ?string $buttonLabel = null, ?string $buttonUrl = null)
    {
        $this->data['template'] = sprintf('/notice/%s.php', $template);
        $this->data['buttonLabel'] = $buttonLabel;
        $this->data['buttonUrl'] = $buttonUrl;
    }

    /**
     * Get a message variable.
     *
     * @param string $name
     *
     * @return string|array<int, string>|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<int, string> $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]);
    }
}