/** * Checks the geocoded data method with a GeocoderRequest */ public function testGeocodedDataWithGeocoderRequest() { $request = new GeocoderRequest(); $request->setAddress('address'); $response = self::$provider->getGeocodedData($request); $this->assertInstanceOf('ivory\\GoogleMapBundle\\Model\\Services\\Geocoding\\Result\\GeocoderResponse', $response); }
/** * {@inheritDoc} */ public function getGeocodedData($request) { if (is_string($request)) { $geocoderRequest = new GeocoderRequest(); $geocoderRequest->setAddress($request); } else { if ($request instanceof GeocoderRequest) { $geocoderRequest = $request; } else { throw new \InvalidArgumentException(sprintf('%s' . PHP_EOL . '%s' . PHP_EOL . '%s' . PHP_EOL . '%s', 'The geolocate argument is invalid.', 'The available prototypes are :', ' - public function geocode(string $address)', ' - public function geocode(Ivory\\GoogleMapBundle\\Model\\Services\\Geocoding\\GeocoderRequest $request)')); } } if (!$geocoderRequest->isValid()) { throw new \InvalidArgumentException('The geocoder request is not valid. It needs at least an address or a coordinate.'); } $url = $this->generateUrl($geocoderRequest); $response = $this->getAdapter()->getContent($url); $normalizedResponse = $this->parse($response); return $this->buildGeocoderResponse($normalizedResponse); }