getGeoNameDataByAddress = $getGeoNameDataByAddress; $this->latLngInterfaceFactory = $latLngInterfaceFactory; $this->addressToString = $addressToString; } /** * @inheritdoc * @throws LocalizedException */ public function execute(AddressInterface $address): LatLngInterface { $cacheKey = $this->addressToString->execute($address); if (!isset($this->latLngCache[$cacheKey])) { $geoNameData = $this->getGeoNameDataByAddress->execute($address); $this->latLngCache[$cacheKey] = $this->latLngInterfaceFactory->create([ 'lat' => (float)$geoNameData['latitude'], 'lng' => (float)$geoNameData['longitude'], ]); } return $this->latLngCache[$cacheKey]; } }