withLimit($limit) ->withLocale($country) ; try { /** @var AddressCollection $collection */ $collection = $this->nominatimGeocoder->geocodeQuery($query); } catch (Exception $e) { throw new \RuntimeException(\sprintf('Unable to get geoloc of %s: %s', $text, $e->getMessage())); } return $collection; } /** * Get the first result of a query as an Address entity instance. */ public function getAddress(string $text): ?Address { $collection = $this->getAddressCollection($text, 1); // invalid address if ($collection->isEmpty()) { return null; } $address = new Address(); /** @var NominatimAddress $geoAddress */ $geoAddress = $collection->first(); $this->adapter->fill($address, $geoAddress); return $address; } }