*/ public function fetchForYear(int $year): array { Assert::greaterThanEq($year, 2026); $url = str_replace(':year', strval($year), self::CALENDAR_API_URL); $response = Http::timeout(self::API_CALL_TIMEOUT_SECONDS)->get($url); throw_unless( $response->successful(), \UnexpectedValueException::class, 'Failed to fetch calendar from api' ); $outputList = $response ->collect() ->map(fn ($label, $date): array => [ 'date' => $date, 'label' => $label, ])->values()->all(); $validator = Validator::make($outputList, [ '*' => 'array', '*.date' => ['required', 'date'], '*.label' => ['required', 'string'], ]); if ($validator->fails()) { throw new \UnexpectedValueException( 'Invalid response: ' . json_encode($validator->errors()->messages()) ); } $timezone = new \DateTimeZone('Europe/Paris'); return array_values(array_map( fn (array $entry): PublicHolidayDto => new PublicHolidayDto( date: CarbonImmutable::parse(Arr::string($entry, 'date'), $timezone), label: Arr::string($entry, 'label'), ), $outputList )); } }