<?php
declare(strict_types=1);

function admin_flash_set(string $type, string $message): void
{
    $_SESSION['_admin_flash'] = ['type' => $type, 'message' => $message];
}

/** @return array{type: string, message: string}|null */
function admin_flash_pull(): ?array
{
    $f = $_SESSION['_admin_flash'] ?? null;
    unset($_SESSION['_admin_flash']);
    if (!is_array($f) || empty($f['message'])) {
        return null;
    }
    return ['type' => (string)($f['type'] ?? 'info'), 'message' => (string)$f['message']];
}
