The topic, if more than one the first is canonical, but all receive delivery */ public readonly array $topic; /** @var string|null The SSE event type */ public readonly ?string $type; /** @var string|null Message data */ public readonly ?string $data; /** @var bool|null Private update*/ public readonly ?bool $private; /** @var string|null Message ID */ public readonly ?string $id; /** @var int SSE retry interval */ public readonly ?int $retry; private readonly int $created; public function __construct( array $topic, ?string $type, ?string $data, ?bool $private, ?string $id, ?int $retry ) { $this->topic = $topic; $this->type = $type; $this->data = $data; $this->private = $private; $this->id = $id; $this->retry = $retry; $this->created = time(); } public function getAge(): int { return time() - $this->created; } public static function fromData(array $data): Message { return new Message( topic: (array)$data['topic'], type: $data['type']??null, data: $data['data']??null, private: match ($data['private']??null) { "on" => true, null => null, default => false }, id: $data['id']??null, retry: $data['retry']??null, ); } }