<?php
namespace App\Shared\Support;

use App\Core\Flash;
use App\Core\Session;

final class FlashSupport
{
    public static function has(?string $type = null): bool
    {
        if (!Flash::has()) {
            return false;
        }

        if ($type === null) {
            return true;
        }

        $flash = Session::get('_flash');
        return is_array($flash) && (($flash['type'] ?? null) === $type);
    }
}
