ContentVersionRepository.php
- Pfad:
src/Infrastructure/Persistence/ContentVersionRepository.php - Namespace: Infrastructure\Persistence
- Zeilen: 84 | Größe: 2,330 Bytes
- Geändert: 2025-12-30 22:27:12 | 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 5
- implements Domain\Repository\ContentVersionRepositoryInterface
- trait Infrastructure\Traits\JsonDecodeTrait
- constructor PDO
- use Domain\Repository\ContentVersionRepositoryInterface
- use Infrastructure\Traits\JsonDecodeTrait
Klassen 1
-
ContentVersionRepositoryclass Zeile 12
Funktionen 5
-
__construct()public Zeile 18 -
findVersionsByOrder()public Zeile 23 -
findLatestVersion()public Zeile 35 -
findVersion()public Zeile 49 -
findCritiquesByVersion()public Zeile 58
Verwendet von 1
Versionen 1
-
v1
2025-12-30 22:27 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Infrastructure\Persistence;
// @responsibility: Persistenz für Content-Versions
use Domain\Repository\ContentVersionRepositoryInterface;
use Infrastructure\Traits\JsonDecodeTrait;
class ContentVersionRepository implements ContentVersionRepositoryInterface
{
use JsonDecodeTrait;
private \PDO $pdo;
public function __construct(\PDO $pdo)
{
$this->pdo = $pdo;
}
public function findVersionsByOrder(int $orderId): array
{
$stmt = $this->pdo->prepare('
SELECT * FROM content_versions
WHERE order_id = :order_id
ORDER BY version_number DESC
');
$stmt->execute(['order_id' => $orderId]);
return $stmt->fetchAll();
}
public function findLatestVersion(int $orderId): ?array
{
$stmt = $this->pdo->prepare('
SELECT * FROM content_versions
WHERE order_id = :order_id
ORDER BY version_number DESC
LIMIT 1
');
$stmt->execute(['order_id' => $orderId]);
$result = $stmt->fetch();
return $result !== false ? $result : null;
}
public function findVersion(int $id): ?array
{
$stmt = $this->pdo->prepare('SELECT * FROM content_versions WHERE id = :id');
$stmt->execute(['id' => $id]);
$result = $stmt->fetch();
return $result !== false ? $result : null;
}
public function findCritiquesByVersion(int $versionId): array
{
$stmt = $this->pdo->prepare("
SELECT cc.*, c.name as critic_name
FROM content_critiques cc
LEFT JOIN content_config c ON cc.critic_id = c.id AND c.type = 'critic'
WHERE cc.version_id = :version_id
ORDER BY cc.round DESC, c.sort_order ASC
");
$stmt->execute(['version_id' => $versionId]);
$results = $stmt->fetchAll();
// Parse feedback JSON and merge with row
foreach ($results as &$row) {
if (isset($row['feedback']) && $row['feedback'] !== '') {
$feedback = $this->decodeJsonArray($row['feedback']);
if ($feedback !== []) {
$row = array_merge($row, $feedback);
}
}
}
return $results;
}
}