<?php

namespace App\Modules\BookingExtra\Application\Find;

use App\Modules\BookingExtra\Domain\IdBookingExtra;
use App\Modules\BookingExtra\Domain\BookingExtra;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class FindBookingExtraQueryHandler implements QueryHandler
{
    public function __construct(private BookingExtraFinder $finder) {}

    public function __invoke(FindBookingExtraQuery $query): FindBookingExtraResponse
    {
        /** @var BookingExtra $model */
        $model = $this->finder->__invoke(
            new IdBookingExtra($query->getId()),
            $query->avoidTransaction(),
            $query->lockInShare()
        );
        return $model->toDTO(FindBookingExtraResponse::class);
    }
}
