feat: Renommage de GetManga à GetMangaById + ajout de axios

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-12 16:41:11 +01:00
parent 666636e5bf
commit 504c62c155
6 changed files with 34 additions and 26 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Domain\Manga\Application\QueryHandler;
use App\Domain\Manga\Application\Query\GetMangaById;
use App\Domain\Manga\Application\Response\MangaResponse;
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
readonly class GetMangaByIdHandler
{
public function __construct(
private MangaRepositoryInterface $mangaRepository
) {}
public function handle(GetMangaById $query): MangaResponse
{
$manga = $this->mangaRepository->findById($query->id);
if (!$manga) {
throw new MangaNotFoundException();
}
return new MangaResponse(
id: $manga->getId()->getValue(),
title: $manga->getTitle()->getValue(),
slug: $manga->getSlug()->getValue(),
description: $manga->getDescription(),
author: $manga->getAuthor(),
publicationYear: $manga->getPublicationYear(),
genres: $manga->getGenres(),
status: $manga->getStatus(),
externalId: $manga->getExternalId()?->getValue(),
imageUrl: $manga->getImageUrl(),
rating: $manga->getRating()
);
}
}