cache->get('bpn_hotels', function (ItemInterface $item) { $item->expiresAfter(3600); $response = $this->apiClient->getBaseData(ApiClient::TYPE_BASE_DATA_HOTELS); if ($response instanceof NotificationResponse) { $this->logger->error('Unable to fetch hotel base data from BusProNet. Code: '.$response->getCode().', Message: '.$response->getMessage()); throw new ApiClientException('Unable to fetch hotel base data from BusProNet'); } return $response->getItems(); }); } catch (ApiClientException|InvalidArgumentException|ResponseParserException $e) { $this->logger->error('Unable to fetch hotel base data from BusProNet: '.$e->getMessage()); $hotels = []; } return $hotels; } public function get(int $busProId): ?Hotel { return $this->getAll()[$busProId] ?? null; } public function findByCode(string $code): array { $hotels = []; foreach ($this->getAll() as $hotel) { if (str_starts_with($hotel->getCode(), $code) || str_ends_with($hotel->getCode(), $code)) { $hotels[] = $hotel; } } return $hotels; } }