feat: ajout de la gestion de la disponibilité des chapitres dans les réponses et les modèles, avec mise à jour des classes concernées

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-03-27 11:15:36 +01:00
parent 346fede878
commit 6ea24deacf
6 changed files with 20 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ use App\Domain\Manga\Application\Response\ChapterListResponse;
use App\Domain\Manga\Application\Response\ChapterResponse;
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
use App\Domain\Manga\Domain\Model\Chapter;
readonly class GetMangaChaptersHandler
{
public function __construct(
@@ -32,12 +32,13 @@ readonly class GetMangaChaptersHandler
return new ChapterListResponse(
chapters: array_map(
fn ($chapter) => new ChapterResponse(
fn (Chapter $chapter) => new ChapterResponse(
id: $chapter->getId(),
number: $chapter->getNumber(),
title: $chapter->getTitle(),
volume: $chapter->getVolume(),
isVisible: $chapter->isVisible(),
isAvailable: $chapter->isAvailable(),
createdAt: $chapter->getCreatedAt()
),
$chapters

View File

@@ -10,6 +10,7 @@ readonly class ChapterResponse
public ?string $title,
public ?int $volume,
public bool $isVisible,
public bool $isAvailable,
public \DateTimeImmutable $createdAt
) {}
}

View File

@@ -13,7 +13,8 @@ readonly class Chapter
private ?string $title,
private ?int $volume,
private bool $isVisible,
private \DateTimeImmutable $createdAt
private bool $isAvailable = false,
private \DateTimeImmutable $createdAt = new \DateTimeImmutable()
) {}
public function getId(): string
@@ -46,6 +47,11 @@ readonly class Chapter
return $this->isVisible;
}
public function isAvailable(): bool
{
return $this->isAvailable;
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;

View File

@@ -13,6 +13,7 @@ readonly class ChapterListItem
public ?string $title,
public ?int $volume,
public bool $isVisible,
public bool $isAvailable,
public string $createdAt
) {}
}

View File

@@ -52,6 +52,7 @@ readonly class GetMangaChaptersStateProvider implements ProviderInterface
title: $chapter->title,
volume: $chapter->volume,
isVisible: $chapter->isVisible,
isAvailable: $chapter->isAvailable,
createdAt: $chapter->createdAt->format(\DateTimeInterface::RFC3339)
);
}

View File

@@ -222,13 +222,13 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
private function toChapterDomain(EntityChapter $entity): Chapter
{
return new Chapter(
new ChapterId((string) $entity->getId()),
$entity->getManga()->getId(),
$entity->getNumber(),
$entity->getTitle(),
$entity->getVolume(),
$entity->isVisible(),
new \DateTimeImmutable()
id: new ChapterId((string) $entity->getId()),
mangaId: $entity->getManga()->getId(),
number: $entity->getNumber(),
title: $entity->getTitle(),
volume: $entity->getVolume(),
isVisible: $entity->isVisible(),
isAvailable: $entity->getCbzPath() !== null
);
}
}