content; } public function getSources(): array { return $this->sources; } public function getVersionNumber(): ?int { return $this->versionNumber; } public function getError(): ?string { return $this->error; } public function hasError(): bool { return $this->error !== null; } public function isSuccess(): bool { return $this->error === null; } /** * Create from Python script result */ public static function fromPythonResult(array $result): self { if (isset($result['error'])) { return new self(error: $result['error']); } return new self( content: $result['content'] ?? '', sources: $result['sources'] ?? [], versionNumber: $result['version_number'] ?? null, ); } /** * Create error result */ public static function error(string $message): self { return new self(error: $message); } /** * Convert to array for view rendering */ public function toArray(): array { return [ 'content' => $this->content, 'sources' => $this->sources, 'version_number' => $this->versionNumber, 'error' => $this->error, ]; } }