feat: SearchManga endpoint + tests

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-10 21:33:34 +01:00
parent 6667cc224b
commit ae0eac3197
25 changed files with 1022 additions and 10 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Tests\Domain\Manga\Adapter;
use App\Domain\Manga\Domain\Contract\Provider\MangaProviderInterface;
use App\Domain\Manga\Domain\Model\Manga;
use App\Domain\Manga\Domain\Model\MangaCollection;
class InMemoryMangaProvider implements MangaProviderInterface
{
/** @var Manga[] */
private array $mangas;
/**
* @param Manga[] $mangas
*/
public function __construct(array $mangas = [])
{
$this->mangas = $mangas;
}
public function search(string $title): MangaCollection
{
$results = array_filter(
$this->mangas,
fn (Manga $manga) => str_contains(
strtolower($manga->getTitle()->getValue()),
strtolower($title)
)
);
return new MangaCollection($results);
}
}