public function geocode($address)
{
if (null === $this->apiKey) {
throw new InvalidCredentials('No API Key provided.');
}
if (!filter_var($address, FILTER_VALIDATE_IP)) {
throw new UnsupportedOperation('The IpInfoDb provider does not support street addresses, only IPv4 addresses.');
}
// This API does not support IPv6
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
throw new UnsupportedOperation('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.');
}
if ('127.0.0.1' === $address) {
return $this->returnResults([$this->getLocalhostDefaults()]);
}
$query = sprintf($this->endpointUrl, $this->apiKey, $address);
return $this->executeQuery($query);
}