<?php

declare(strict_types=1);

namespace App\State;

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\ApiResource\PublicHoliday;
use App\Service\PublicHolidayServiceInterface;

final readonly class PublicHolidayYearProvider implements ProviderInterface
{
    public function __construct(
        private PublicHolidayServiceInterface $PublicHolidayYearService
    ) {}

    public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?object
    {
        $holidaysDay = $this->PublicHolidayYearService->getHolidaysDayByYears($uriVariables['zone'], $uriVariables['years']);

        return $holidaysDay ? new PublicHoliday($holidaysDay) : null;
    }
}
