feat: endpoint FetchMangaChapters et tests

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-11 18:00:49 +01:00
parent 3dc0a0b406
commit 879b8fa2dc
20 changed files with 424 additions and 45 deletions

View File

@@ -9,6 +9,7 @@ class InMemoryMangadexClient implements MangadexClientInterface
private array $mangas = [];
private array $feeds = [];
private array $aggregates = [];
private array $mangaFeeds = [];
public function __construct(
array $mangas = [],
@@ -61,22 +62,7 @@ class InMemoryMangadexClient implements MangadexClientInterface
public function getMangaFeed(string $mangaId, int $offset = 0, int $limit = 500, string $order = 'asc'): array
{
if (!isset($this->feeds[$mangaId])) {
return [
'data' => [],
'total' => 0
];
}
$feed = $this->feeds[$mangaId];
if ($order === 'desc') {
$feed = array_reverse($feed);
}
return [
'data' => array_slice($feed, $offset, $limit),
'total' => count($feed)
];
return $this->mangaFeeds[$mangaId] ?? ['data' => []];
}
public function getMangaAggregate(string $mangaId): array
@@ -120,4 +106,9 @@ class InMemoryMangadexClient implements MangadexClientInterface
{
$this->aggregates[$mangaId] = $aggregate;
}
public function setMangaFeed(string $mangaId, array $feed): void
{
$this->mangaFeeds[$mangaId] = $feed;
}
}