TaskCommentRepository.php
- Pfad:
src/Infrastructure/Persistence/TaskCommentRepository.php - Namespace: Infrastructure\Persistence
- Zeilen: 95 | Größe: 2,733 Bytes
- Geändert: 2025-12-25 12:51:04 | 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 4
- implements Domain\Repository\TaskCommentRepositoryInterface
- constructor PDO
- use Domain\Entity\TaskComment
- use Domain\Repository\TaskCommentRepositoryInterface
Klassen 1
-
TaskCommentRepositoryclass Zeile 12
Funktionen 6
-
__construct()public Zeile 16 -
find()public Zeile 21 -
findByTaskId()public Zeile 30 -
findByType()public Zeile 47 -
save()public Zeile 62 -
delete()public Zeile 88
Verwendet von 9
- AssignTaskUseCase.php constructor
- AssignTaskUseCase.php use
- CreateTaskUseCase.php constructor
- CreateTaskUseCase.php use
- SaveTaskResultUseCase.php constructor
- SaveTaskResultUseCase.php use
- TaskServiceProvider.php use
- UpdateTaskStatusUseCase.php constructor
- UpdateTaskStatusUseCase.php use
Versionen 5
-
v5
2025-12-25 12:51 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v4
2025-12-25 10:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v3
2025-12-25 10:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-23 08:04 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-22 10:11 | 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 Task-Kommentare
use Domain\Entity\TaskComment;
use Domain\Repository\TaskCommentRepositoryInterface;
class TaskCommentRepository implements TaskCommentRepositoryInterface
{
private \PDO $pdo;
public function __construct(\PDO $pdo)
{
$this->pdo = $pdo;
}
public function find(int $id): ?TaskComment
{
$stmt = $this->pdo->prepare('SELECT * FROM task_comments WHERE id = :id');
$stmt->execute(['id' => $id]);
$row = $stmt->fetch();
return $row !== false ? TaskComment::fromArray($row) : null;
}
public function findByTaskId(int $taskId, int $limit = 50): array
{
$stmt = $this->pdo->prepare(
'SELECT * FROM task_comments WHERE task_id = :task_id ORDER BY created_at DESC LIMIT :limit'
);
$stmt->bindValue(':task_id', $taskId, \PDO::PARAM_INT);
$stmt->bindValue(':limit', $limit, \PDO::PARAM_INT);
$stmt->execute();
$comments = [];
while ($row = $stmt->fetch()) {
$comments[] = TaskComment::fromArray($row);
}
return $comments;
}
public function findByType(int $taskId, string $commentType): array
{
$stmt = $this->pdo->prepare(
'SELECT * FROM task_comments WHERE task_id = :task_id AND comment_type = :type ORDER BY created_at DESC'
);
$stmt->execute(['task_id' => $taskId, 'type' => $commentType]);
$comments = [];
while ($row = $stmt->fetch()) {
$comments[] = TaskComment::fromArray($row);
}
return $comments;
}
public function save(TaskComment $comment): int
{
$sql = 'INSERT INTO task_comments (
task_id, author, author_type, comment_type,
content, metadata, created_at
) VALUES (
:task_id, :author, :author_type, :comment_type,
:content, :metadata, :created_at
)';
$stmt = $this->pdo->prepare($sql);
$data = $comment->toArray();
$stmt->execute([
'task_id' => $data['task_id'],
'author' => $data['author'],
'author_type' => $data['author_type'],
'comment_type' => $data['comment_type'],
'content' => $data['content'],
'metadata' => json_encode($data['metadata']),
'created_at' => $data['created_at'],
]);
return (int) $this->pdo->lastInsertId();
}
public function delete(int $id): bool
{
$stmt = $this->pdo->prepare('DELETE FROM task_comments WHERE id = :id');
return $stmt->execute(['id' => $id]);
}
}