{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Protokoll\/ViewProtokollUseCase.php",
"old_string": "<?php\n\nnamespace UseCases\\Protokoll;\n\nuse Domain\\ValueObject\\Pagination;\nuse Infrastructure\\Persistence\\KiProtokollRepository;\n\nfinal class ViewProtokollUseCase",
"new_string": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Protokoll;\n\n\/\/ @responsibility: Liest KI-Protokoll-Einträge mit Filterung und Pagination\n\nuse Domain\\ValueObject\\Pagination;\nuse Infrastructure\\Persistence\\KiProtokollRepository;\n\nfinal class ViewProtokollUseCase"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Protokoll\/ViewProtokollUseCase.php",
"oldString": "<?php\n\nnamespace UseCases\\Protokoll;\n\nuse Domain\\ValueObject\\Pagination;\nuse Infrastructure\\Persistence\\KiProtokollRepository;\n\nfinal class ViewProtokollUseCase",
"newString": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Protokoll;\n\n\/\/ @responsibility: Liest KI-Protokoll-Einträge mit Filterung und Pagination\n\nuse Domain\\ValueObject\\Pagination;\nuse Infrastructure\\Persistence\\KiProtokollRepository;\n\nfinal class ViewProtokollUseCase",
"originalFile": "<?php\n\nnamespace UseCases\\Protokoll;\n\nuse Domain\\ValueObject\\Pagination;\nuse Infrastructure\\Persistence\\KiProtokollRepository;\n\nfinal class ViewProtokollUseCase\n{\n private KiProtokollRepository $protokollRepo;\n\n public function __construct(?KiProtokollRepository $protokollRepo = null)\n {\n $this->protokollRepo = $protokollRepo ?? new KiProtokollRepository();\n }\n\n public function getPaginated(\n ?string $search,\n ?string $status,\n ?string $model,\n Pagination $pagination\n ): array {\n $totalCount = $this->protokollRepo->countFiltered($search, $status, $model);\n $updatedPagination = $pagination->withTotal($totalCount);\n\n $entries = $this->protokollRepo->findPaginated(\n $search,\n $status,\n $model,\n $updatedPagination->limit,\n $updatedPagination->offset\n );\n\n return [\n 'entries' => array_map(fn (array $row) => ProtokollDTO::fromArray($row), $entries),\n 'pagination' => $updatedPagination,\n ];\n }\n\n public function getById(int $id): ?ProtokollDTO\n {\n $entry = $this->protokollRepo->findById($id);\n\n if ($entry === null) {\n return null;\n }\n\n $entry['request_formatted'] = $this->formatJson($entry['request']);\n $entry['response_formatted'] = $this->formatJson($entry['response']);\n\n return ProtokollDTO::fromArray($entry);\n }\n\n public function getNavigation(int $id): array\n {\n return [\n 'prevId' => $this->protokollRepo->findPreviousId($id),\n 'nextId' => $this->protokollRepo->findNextId($id),\n ];\n }\n\n public function getStatistics(): array\n {\n return $this->protokollRepo->getStatistics();\n }\n\n public function getDistinctModels(): array\n {\n return $this->protokollRepo->getDistinctModels();\n }\n\n private function formatJson(?string $json): string\n {\n if ($json === null || $json === '') {\n return '-';\n }\n\n $decoded = json_decode($json, true);\n if ($decoded === null) {\n return htmlspecialchars($json);\n }\n\n $formatted = json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);\n\n return $formatted !== false ? $formatted : htmlspecialchars($json);\n }\n}\n",
"structuredPatch": [
{
"oldStart": 1,
"oldLines": 7,
"newStart": 1,
"newLines": 11,
"lines": [
" <?php",
" ",
"+declare(strict_types=1);",
"+",
" namespace UseCases\\Protokoll;",
" ",
"+\/\/ @responsibility: Liest KI-Protokoll-Einträge mit Filterung und Pagination",
"+",
" use Domain\\ValueObject\\Pagination;",
" use Infrastructure\\Persistence\\KiProtokollRepository;",
" "
]
}
],
"userModified": false,
"replaceAll": false
}
}