<?php

namespace App\Modules\Room\Application\ReloadPassengerAmount;

use App\Modules\Room\Domain\IdRoom;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class ReloadPassengerAmountRoomQueryHandler implements QueryHandler
{
    public function __construct(private RoomPassengerAmountReloader $finder) {}

    public function __invoke(ReloadPassengerAmountRoomQuery $query): ReloadPassengerAmountRoomResponse
    {
        $this->finder->__invoke(
            new IdRoom($query->getId()),
            $query->avoidTransaction(),
            $query->lockInShare()
        );
        return new ReloadPassengerAmountRoomResponse();
    }
}
