ViewProtokollUseCase.php
- Pfad:
src/UseCases/Protokoll/ViewProtokollUseCase.php - Namespace: UseCases\Protokoll
- Zeilen: 90 | Größe: 2,349 Bytes
- Geändert: 2025-12-23 08:49:24 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 3
- constructor Infrastructure\Persistence\KiProtokollRepository
- use Domain\ValueObject\Pagination
- use Infrastructure\Persistence\KiProtokollRepository
Klassen 1
-
ViewProtokollUseCaseclass Zeile 12
Funktionen 7
-
__construct()public Zeile 14 -
getPaginated()public Zeile 19 -
getById()public Zeile 42 -
getNavigation()public Zeile 56 -
getStatistics()public Zeile 64 -
getDistinctModels()public Zeile 69 -
formatJson()private Zeile 74
Verwendet von 2
- ProtokollController.php use
- ProtokollController.php constructor
Versionen 2
-
v2
2025-12-23 08:17 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-23 07:55 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?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;
final class ViewProtokollUseCase
{
public function __construct(
private KiProtokollRepository $protokollRepo
) {
}
public function getPaginated(
?string $search,
?string $status,
?string $model,
Pagination $pagination
): array {
$totalCount = $this->protokollRepo->countFiltered($search, $status, $model);
$updatedPagination = $pagination->withTotal($totalCount);
$entries = $this->protokollRepo->findPaginated(
$search,
$status,
$model,
$updatedPagination->limit,
$updatedPagination->offset
);
return [
'entries' => array_map(fn (array $row) => ProtokollDTO::fromArray($row), $entries),
'pagination' => $updatedPagination,
];
}
public function getById(int $id): ?ProtokollDTO
{
$entry = $this->protokollRepo->findById($id);
if ($entry === null) {
return null;
}
$entry['request_formatted'] = $this->formatJson($entry['request']);
$entry['response_formatted'] = $this->formatJson($entry['response']);
return ProtokollDTO::fromArray($entry);
}
public function getNavigation(int $id): array
{
return [
'prevId' => $this->protokollRepo->findPreviousId($id),
'nextId' => $this->protokollRepo->findNextId($id),
];
}
public function getStatistics(): array
{
return $this->protokollRepo->getStatistics();
}
public function getDistinctModels(): array
{
return $this->protokollRepo->getDistinctModels();
}
private function formatJson(?string $json): string
{
if ($json === null || $json === '') {
return '-';
}
$decoded = json_decode($json, true);
if ($decoded === null) {
return htmlspecialchars($json);
}
$formatted = json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
return $formatted !== false ? $formatted : htmlspecialchars($json);
}
}