Files
papa-kind-treff.info/src/App/Flash.php
Lars Gebhardt-Kusche dca3ce93e6
All checks were successful
Deploy / deploy (push) Successful in 49s
refresh
2026-07-16 01:21:29 +02:00

34 lines
747 B
PHP
Executable File

<?php
declare(strict_types=1);
namespace App;
final class Flash
{
public function __construct(private SessionManager $session) {}
public function set(string $type, string $message): void
{
$this->session->start();
$_SESSION['flash'] = [
'type' => $type,
'message' => $message,
];
}
public function get(): ?array
{
$this->session->start();
if (empty($_SESSION['flash']) || !is_array($_SESSION['flash'])) {
return null;
}
$f = $_SESSION['flash'];
unset($_SESSION['flash']);
return [
'type' => (string)($f['type'] ?? 'info'),
'message' => (string)($f['message'] ?? ''),
];
}
}