cache->get('bpn_countries', function (ItemInterface $item) { $item->expiresAfter(3600); $response = $this->apiClient->getBaseData(ApiClient::TYPE_BASE_DATA_COUNTRIES); if ($response instanceof NotificationResponse) { $this->logger->error('Unable to fetch country base data from BusProNet. Code: '.$response->getCode().', Message: '.$response->getMessage()); throw new ApiClientException('Unable to fetch country base data from BusProNet'); } return $response->getItems(); }); } catch (ApiClientException|ResponseParserException $e) { $this->logger->error('Unable to fetch country base data from BusProNet: '.$e->getMessage()); $countries = []; } return $countries; } public function get(?string $token): ?Country { if (null === $token) { return null; } return $this->getAll()[$token] ?? null; } }