feat: Reader beginning
This commit is contained in:
parent
e90c0a140e
commit
55945adc53
@@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user