|null */ public function statusesFor( Accommodation $accommodation, \DateTimeImmutable $dateFrom, \DateTimeImmutable $dateTo, ): ?array { $hotelCode = $accommodation->getCalendarCode(); if (null === $hotelCode || '' === $hotelCode) { return null; } if (!$this->isUsable($accommodation, $hotelCode)) { return null; } $statuses = []; foreach ($this->dayRepository->findByHotelCodeAndDateRange($hotelCode, $dateFrom, $dateTo) as $date => $day) { $statuses[$date] = $day->getStatus(); } return $statuses; } private function isUsable(Accommodation $accommodation, string $hotelCode): bool { $syncedAt = $this->syncStateRepository->findOneByAccommodation($accommodation)?->getSyncedAt(); if (null === $syncedAt) { $this->logger->error('No contingent snapshot has been synced yet', ['hotelCode' => $hotelCode]); return false; } if ($syncedAt < CarbonImmutable::now()->modify(self::MAX_SNAPSHOT_AGE)) { $this->logger->error('Contingent snapshot is stale', [ 'hotelCode' => $hotelCode, 'syncedAt' => $syncedAt->format(\DateTimeInterface::ATOM), ]); return false; } return true; } }