<?php
declare(strict_types=1);

/**
 * One-shot messages that survive a redirect.
 * Kinds: ok | warn | error
 */
final class Flash
{
    public static function add(string $kind, string $message): void
    {
        $_SESSION['flash'][] = [$kind, $message];
    }

    /** Returns everything queued and clears it. */
    public static function take(): array
    {
        $items = $_SESSION['flash'] ?? [];
        unset($_SESSION['flash']);
        return $items;
    }
}
