AIResponse.php
- Pfad:
src/Infrastructure/AI/AIResponse.php - Namespace: Infrastructure\AI
- Zeilen: 138 | Größe: 3,208 Bytes
- Geändert: 2025-12-23 08:00:16 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 94
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 70 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Klassen 1
-
AIResponseclass Zeile 9
Funktionen 13
-
__construct()public Zeile 20 -
success()public Zeile 40 -
error()public Zeile 60 -
isSuccess()public Zeile 74 -
getContent()public Zeile 79 -
getErrorMessage()public Zeile 84 -
getTokensInput()public Zeile 89 -
getTokensOutput()public Zeile 94 -
getTokensTotal()public Zeile 99 -
getDurationMs()public Zeile 108 -
getModel()public Zeile 113 -
getMetadata()public Zeile 118 -
toArray()public Zeile 123
Versionen 1
-
v1
2025-12-23 08:00 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Infrastructure\AI;
// @responsibility: Datenstruktur für AI-Antworten mit Tokens und Metadaten
class AIResponse
{
private bool $success;
private ?string $content;
private ?string $errorMessage;
private ?int $tokensInput;
private ?int $tokensOutput;
private ?int $durationMs;
private string $model;
private array $metadata;
public function __construct(
bool $success,
?string $content = null,
?string $errorMessage = null,
?int $tokensInput = null,
?int $tokensOutput = null,
?int $durationMs = null,
string $model = '',
array $metadata = []
) {
$this->success = $success;
$this->content = $content;
$this->errorMessage = $errorMessage;
$this->tokensInput = $tokensInput;
$this->tokensOutput = $tokensOutput;
$this->durationMs = $durationMs;
$this->model = $model;
$this->metadata = $metadata;
}
public static function success(
string $content,
?int $tokensInput = null,
?int $tokensOutput = null,
?int $durationMs = null,
string $model = '',
array $metadata = []
): self {
return new self(
true,
$content,
null,
$tokensInput,
$tokensOutput,
$durationMs,
$model,
$metadata
);
}
public static function error(string $errorMessage, string $model = '', array $metadata = []): self
{
return new self(
false,
null,
$errorMessage,
null,
null,
null,
$model,
$metadata
);
}
public function isSuccess(): bool
{
return $this->success;
}
public function getContent(): ?string
{
return $this->content;
}
public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
public function getTokensInput(): ?int
{
return $this->tokensInput;
}
public function getTokensOutput(): ?int
{
return $this->tokensOutput;
}
public function getTokensTotal(): ?int
{
if ($this->tokensInput !== null && $this->tokensOutput !== null) {
return $this->tokensInput + $this->tokensOutput;
}
return null;
}
public function getDurationMs(): ?int
{
return $this->durationMs;
}
public function getModel(): string
{
return $this->model;
}
public function getMetadata(): array
{
return $this->metadata;
}
public function toArray(): array
{
return [
'success' => $this->success,
'content' => $this->content,
'error_message' => $this->errorMessage,
'tokens_input' => $this->tokensInput,
'tokens_output' => $this->tokensOutput,
'tokens_total' => $this->getTokensTotal(),
'duration_ms' => $this->durationMs,
'model' => $this->model,
'metadata' => $this->metadata,
];
}
}