feat: Ajout d'un endpoint getBySlug

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-12 16:55:44 +01:00
parent 504c62c155
commit 30d26f530d
9 changed files with 265 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ use App\Domain\Manga\Domain\Model\Chapter;
use App\Domain\Manga\Domain\Model\Manga;
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
use App\Domain\Manga\Domain\Model\ValueObject\ExternalId;
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
class InMemoryMangaRepository implements MangaRepositoryInterface
{
@@ -47,6 +48,16 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
return $this->mangas[$id] ?? null;
}
public function findBySlug(MangaSlug $slug): ?Manga
{
foreach ($this->mangas as $manga) {
if ($manga->getSlug()->getValue() === $slug->getValue()) {
return $manga;
}
}
return null;
}
public function save(Manga $manga): void
{
$this->mangas[$manga->getId()->getValue()] = $manga;