public function geocode($address)
{
if (null === $this->apiKey) {
throw new InvalidCredentials('No API key provided.');
}
// This API doesn't handle IPs
if (filter_var($address, FILTER_VALIDATE_IP)) {
throw new UnsupportedOperation('The BingMaps provider does not support IP addresses, only street addresses.');
}
$query = sprintf(self::GEOCODE_ENDPOINT_URL, $this->getLimit(), urlencode($address), $this->apiKey);
return $this->executeQuery($query);
}
/** * @expectedException \Geocoder\Exception\UnsupportedOperation * @expectedExceptionMessage The BingMaps provider does not support IP addresses, only street addresses. */ public function testGeocodeWithRealIPv6() { if (!isset($_SERVER['BINGMAPS_API_KEY'])) { $this->markTestSkipped('You need to configure the BINGMAPS_API_KEY value in phpunit.xml'); } $provider = new BingMaps($this->getAdapter($_SERVER['BINGMAPS_API_KEY']), $_SERVER['BINGMAPS_API_KEY']); $provider->geocode('::ffff:88.188.221.14'); }