<?php

namespace Linksy\SearchAndReplace\Plugli\Standard\Helpers;

/**
 * Hadndle incoming Notices.
 *
 * @since      1.0.1
 * @package    Plugli
 * @subpackage Plugli\Standard
 * @author     Plugli Team <https://plugli.com>
 */
/**
 * Notices class.
 */
class Notices
{
    private $message;
    private $status;
    // success | error | info
    private $is_dismissible;
    function __construct($message, $status = 'info', $is_dismissible = \false)
    {
        $this->message = $message;
        $this->status = $status;
        $this->is_dismissible = $is_dismissible;
        add_action('admin_notices', array($this, 'render'));
    }
    /**
     * Factory.
     *
     * @param string $caller File path to calling plugin/theme.
     */
    public static function instance($message, $status = 'info', $is_dismissible = \false)
    {
        static $instance = null;
        if (null === $instance) {
            $instance = new self($message, $status, $is_dismissible);
        }
        return $instance;
    }
    function render()
    {
        $class = 'notice notice-' . $this->status;
        if ($this->is_dismissible) {
            $class .= ' is-dismissible';
        }
        $message = __($this->message, 'plugli');
        printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message);
    }
}
