<?php

declare(strict_types=1);

namespace App\State;

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

final readonly class PublicHolidayProvider implements ProviderInterface
{
    public function __construct(
        private PublicHolidayServiceInterface $publicHolidayService
    ) {}

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

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