chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Framework\Router\Result;
/**
* Repräsentiert ein einzelnes Server-Sent Event
*/
final readonly class SseEvent
{
/**
* @param string $data Der Dateninhalt des Events
* @param string|null $event Der Event-Typ (optional)
* @param string|null $id Die Event-ID (optional)
* @param int|null $retry Retry-Intervall in Millisekunden (optional)
*/
public function __construct(
public string $data,
public ?string $event = null,
public ?string $id = null,
public ?int $retry = null
) {}
/**
* Formatiert das Event in das SSE-Protokollformat
*/
public function format(): string
{
$formatted = [];
if ($this->id !== null) {
$formatted[] = "id: {$this->id}";
}
if ($this->event !== null) {
$formatted[] = "event: {$this->event}";
}
if ($this->retry !== null) {
$formatted[] = "retry: {$this->retry}";
}
// Mehrzeilige Daten unterstützen
foreach (explode("\n", $this->data) as $line) {
$formatted[] = "data: {$line}";
}
$formatted[] = ''; // Leere Zeile am Ende
return implode("\n", $formatted);
}
}