chapters as $chapterData) { $chapter = $this->mangaRepository->findChapterById($chapterData->id); if (!$chapter) { throw new ChapterNotFoundException($chapterData->id); } $manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue()); if (null !== $chapterData->title) { $manga->updateChapterTitle($chapter, $chapterData->title); } if (null !== $chapterData->volume) { $manga->updateChapterVolume($chapter, $chapterData->volume); } $this->mangaRepository->save($manga); } } }