Files
Mangarr/tests/Domain/Manga/Adapter/InMemoryMangaProvider.php
ext.jeremy.guillot@maxicoffee.domains 814fe46ce5 feat(manga): implémenter la page Découvrir avec recommandations MangaDex
- Endpoint GET /api/manga-discover via DiscoverMangaStateProvider + DiscoverMangaHandler
- Algorithme : top 5 manga de la collection → appel /manga/{id}/recommendation
  par source → agrégation avec système de votes (multi-sources = plus pertinent)
- Filtrage : tags exclus (Oneshot, Doujinshi, Self-Published), contentRating,
  et suppression des manga déjà en bibliothèque
- Page Vue DiscoverPage.vue : chargement auto au montage, bouton Actualiser,
  modal détail, ajout à la bibliothèque
- Adapteurs InMemory de test mis à jour (discover + getMangaRecommendations)
2026-03-15 21:43:57 +01:00

51 lines
1.3 KiB
PHP

<?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;
use App\Domain\Manga\Domain\Model\ValueObject\ExternalId;
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);
}
public function findByExternalId(ExternalId $externalId): ?Manga
{
foreach ($this->mangas as $manga) {
if ($manga->getExternalId() && $manga->getExternalId()->getValue() === $externalId->getValue()) {
return $manga;
}
}
return null;
}
public function discover(array $sourceExternalIds): MangaCollection
{
return new MangaCollection([]);
}
}