<?php

namespace App\Modules\BookingTour\Application\Index;

use App\Modules\BookingTour\Application\BookingTourResponse;
use App\Modules\BookingTour\Domain\BookingTour;
use App\Modules\BookingTour\Domain\IdBookingTour;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class IndexBookingTourQueryHandler implements QueryHandler
{
    public function __construct(private BookingTourIndexer $indexer) {}

    public function __invoke(IndexBookingTourQuery $query): BookingTourResponse
    {
        /** @var BookingTour $model */
        $model = $this->indexer->__invoke(
            new IdBookingTour($query->id())
        );
        return $model->toDTO(BookingTourResponse::class);
    }
}
