feat: Ajout d'un endpoint getBySlug
This commit is contained in:
parent
504c62c155
commit
30d26f530d
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user