<?php

namespace App\Modules\Report\Booking\Application\TourByDay;

use App\Modules\Report\Booking\Domain\TourByDay\TourByDayGroupBy;
use App\Modules\Report\Booking\Domain\TourByDay\TourByDayShowBy;
use App\Modules\Report\Booking\Domain\TourByDay\TourByDayType;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;
use App\Modules\Shared\Domain\DateEnd;
use App\Modules\Shared\Domain\DateStart;

final class ReportTourByDayBookingQueryHandler implements QueryHandler
{
    public function __construct(
        private TourByDayBookingReporter $reporter
    ) {}

    public function __invoke(ReportTourByDayBookingQuery $query): ReportTourByDayBookingResponse
    {
        return new ReportTourByDayBookingResponse(
            $this->reporter->__invoke(
                new DateStart($query->dateStart),
                new DateEnd($query->dateEnd),
                new TourByDayType($query->type),
                $query->id,
                new TourByDayShowBy($query->showBy),
                new TourByDayGroupBy($query->groupBy),
            )
        );
    }
}
