chapters as $chapter) { if ($chapter->mangaId === $mangaId && $chapter->chapterNumber === $chapterNumber) { return $chapter; } } throw new \RuntimeException('Chapter not found'); } public function save(Chapter $chapter): void { $this->chapters[$chapter->id] = $chapter; } public function clear(): void { $this->chapters = []; } }