*/ public array $sentRaw = []; /** @var array */ public array $sentDecoded = []; /** * @param string $data */ public function send($data): self { $this->sentRaw[] = (string) $data; $decoded = json_decode((string) $data, true); $this->sentDecoded[] = (json_last_error() === JSON_ERROR_NONE) ? $decoded : (string) $data; return $this; } public function close(): void { // no-op } /** * Return the most recent payload sent (decoded if it was JSON). */ public function lastPayload(): mixed { return $this->sentDecoded[array_key_last($this->sentDecoded)] ?? null; } }