query->get('from', ''); $toRaw = (string) $request->query->get('to', ''); if ('' !== $fromRaw && '' !== $toRaw) { $fromYear = (int) new DateTimeImmutable($fromRaw)->format('Y'); $toYear = (int) new DateTimeImmutable($toRaw)->format('Y'); } else { $fromYear = $toYear = (int) ($request->query->get('year') ?: date('Y')); } $holidays = []; for ($year = $fromYear; $year <= $toYear; ++$year) { $holidays += $this->holidayProvider->getHolidays($year); } return $this->json($holidays); } }