<?php

declare(strict_types=1);

namespace App\Core;

final class Flash
{
    private const KEY = '_flash';

    public static function set(string $type, string $message): void
    {
        Session::put(self::KEY, ['type' => $type, 'message' => $message]);
    }

    public static function get(): ?array
    {
        $flash = Session::pull(self::KEY);
        return is_array($flash) ? $flash : null;
    }

    public static function has(): bool
    {
        return is_array(Session::get(self::KEY));
    }
}
