addressInterfaceFactory = $addressInterfaceFactory; $this->getLatLngFromAddress = $getLatLngFromAddress; $this->latLngInterfaceFactory = $latLngInterfaceFactory; } /** * Get latitude and longitude from source * * @param SourceInterface $source * @return LatLngInterface */ public function execute(SourceInterface $source): LatLngInterface { if (!$source->getLatitude() || !$source->getLongitude()) { $sourceAddress = $this->addressInterfaceFactory->create([ 'country' => $source->getCountryId() ?? '', 'postcode' => $source->getPostcode() ?? '', 'street' => $source->getStreet() ?? '', 'region' => $source->getRegion() ?? '', 'city' => $source->getCity() ?? '' ]); return $this->getLatLngFromAddress->execute($sourceAddress); } return $this->latLngInterfaceFactory->create([ 'lat' => (float) $source->getLatitude(), 'lng' => (float) $source->getLongitude() ]); } }