*/ public array $comments = []; private int $nextId = 1; public function findForTask(int $taskId, int $commentId): ?TaskComment { $comment = $this->comments[$commentId] ?? null; return $comment !== null && $comment->taskId() === $taskId ? clone $comment : null; } public function save(TaskComment $comment): TaskComment { $id = $comment->id() ?? $this->nextId++; $this->comments[$id] = TaskComment::reconstitute($id, $comment->taskId(), $comment->authorId(), $comment->body(), $comment->createdAt(), $comment->editedAt()); return clone $this->comments[$id]; } public function delete(TaskComment $comment): void { unset($this->comments[$comment->id()]); } }