addType('id', 'integer'); $this->addType('runId', 'integer'); $this->addType('sequence', 'integer'); $this->addType('durationMs', 'integer'); $this->addType('createdAt', 'integer'); } public function jsonSerialize(): array { return [ 'id' => $this->id, 'run_id' => $this->runId, 'sequence' => $this->sequence, 'event_type' => $this->eventType, 'status' => $this->status, 'tool_name' => $this->toolName, 'duration_ms' => $this->durationMs, 'payload_json' => $this->decodeJson($this->payloadJson), 'payload_preview' => $this->payloadPreview, 'result_json' => $this->decodeJson($this->resultJson), 'result_preview' => $this->resultPreview, 'error_message' => $this->errorMessage, 'created_at' => $this->createdAt, ]; } /** * @return mixed */ private function decodeJson(?string $json) { if ($json === null || $json === '') { return null; } $decoded = json_decode($json, true); return json_last_error() === JSON_ERROR_NONE ? $decoded : $json; } }