feat: Reader beginning

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-16 16:15:42 +01:00
parent e90c0a140e
commit 55945adc53
37 changed files with 1057 additions and 47 deletions

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Domain\Reader\Application\QueryHandler;
use App\Domain\Reader\Application\Query\GetChapterContext;
use App\Domain\Reader\Application\Response\ChapterContextResponse;
use App\Domain\Reader\Domain\Contract\Repository\ChapterRepositoryInterface;
use App\Domain\Reader\Domain\ValueObject\ChapterId;
final readonly class GetChapterContextHandler
{
public function __construct(
private ChapterRepositoryInterface $chapterRepository
) {
}
public function handle(GetChapterContext $query): ChapterContextResponse
{
$chapterId = new ChapterId($query->getChapterId());
$context = $this->chapterRepository->getChapterContext($chapterId);
return new ChapterContextResponse(
$query->getChapterId(),
$context->getChapterTitle(),
$context->getNumber(),
$context->getTotalPages(),
$context->getPreviousChapterId()?->getValue(),
$context->getNextChapterId()?->getValue(),
);
}
}