<?php

namespace App\Modules\Provider\Application\PassengerDistributionListPassenger;

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

class PassengerDistributionListPassengerQueryHandler implements QueryHandler
{
    public function __construct(
        private ProviderDistributionListPassengerSearcher $passengerDistributionListPassengerSearcher,
        private ProviderDistributionListPassengerSearcherCount $passengerDistributionListPassengerCountSearcher,
    ) {}

    public function __invoke(PassengerDistributionListPassengerQuery $query)
    {
        $search = $this->passengerDistributionListPassengerSearcher->__invoke($query->search(), $query->dateStart(), $query->dateEnd(), $query->idProvider(), $query->page(), $query->pageSize());
        $count = $this->passengerDistributionListPassengerCountSearcher->__invoke($query->search(), $query->dateStart(), $query->dateEnd(), $query->idProvider());
        return new PassengerDistributionListPassengerQueryResponse($search, $count);
    }
}
