<?php

namespace Amwdeveloper\model;

class message
{
    /** @var string|null */
    protected $message;

    /** @var string|null */
    protected $class;

    public function text(string $message): message
    {
        $this->message = $message;
        return $this;
    }

    public function class(string $class): message
    {
        $this->class = $class;
        return $this;
    }

    public function flash(bool $clear = false, bool $refresh = false, string $redirect = ""): message
    {
        echo json_encode(['message' => "<div class=\"{$this->class}\"></div> <p>{$this->message}</p> <a href=\"#\">Ok</a>", 'clear' => $clear, 'refresh' => $refresh, 'redirect' => $redirect]);
        return $this;
    }
}
