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,92 @@
<?php
declare(strict_types=1);
namespace App\Framework\Router\Result;
use App\Framework\Http\SseStream;
use App\Framework\Http\Status;
use App\Framework\Router\ActionResult;
/**
* Erweiterte SSE-Klasse, die eine Callback-Funktion für Live-Updates unterstützt
*/
final class SseResultWithCallback implements ActionResult
{
/**
* @var callable|null Callback-Funktion, die während des Streamings ausgeführt wird
*/
private $callback = null;
/**
* @var int Maximale Streaming-Dauer in Sekunden (0 = unbegrenzt)
*/
private int $maxDuration = 0;
/**
* @var int Intervall für Heartbeats in Sekunden
*/
private int $heartbeatInterval = 30;
public function __construct(
public readonly Status $status = Status::OK,
public readonly array $headers = []
) {}
/**
* Setzt die Callback-Funktion, die während des Streamings aufgerufen wird
* Der Callback erhält den SseStream als Parameter
*
* @param callable $callback Funktion mit Signatur: function(SseStream $stream): void
*/
public function setCallback(callable $callback): self
{
$this->callback = $callback;
return $this;
}
/**
* Setzt die maximale Streaming-Dauer
*
* @param int $seconds Maximale Dauer in Sekunden (0 = unbegrenzt)
*/
public function setMaxDuration(int $seconds): self
{
$this->maxDuration = $seconds;
return $this;
}
/**
* Setzt das Intervall für Heartbeats
*
* @param int $seconds Intervall in Sekunden
*/
public function setHeartbeatInterval(int $seconds): self
{
$this->heartbeatInterval = $seconds;
return $this;
}
/**
* Gibt den Callback zurück
*/
public function getCallback(): ?callable
{
return $this->callback;
}
/**
* Gibt die maximale Streaming-Dauer zurück
*/
public function getMaxDuration(): int
{
return $this->maxDuration;
}
/**
* Gibt das Heartbeat-Intervall zurück
*/
public function getHeartbeatInterval(): int
{
return $this->heartbeatInterval;
}
}