Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94f4f9d5e6 | ||
|
|
dac9e94304 | ||
|
|
51e2f84d07 | ||
|
|
42efc47796 | ||
|
|
36624ae87a | ||
|
|
08697f2e7b | ||
|
|
2f9746c32b | ||
|
|
920a92f352 | ||
|
|
0d90c7a78e | ||
|
|
d52a0b057e | ||
|
|
5c4dd5b1e5 | ||
|
|
942ba4b8f5 | ||
|
|
a9fa7194aa | ||
|
|
13fbcae21c | ||
|
|
1925936b26 | ||
|
|
9384f93a72 | ||
|
|
9a7d49f683 | ||
|
|
b3e5aaac21 | ||
|
|
7d78bd9b2e | ||
|
|
6cf9b98993 | ||
|
|
a5fe44c3d3 | ||
|
|
6b919b4cba | ||
|
|
e441dbb64e | ||
|
|
adffe69dd2 | ||
|
|
04ccb67cea | ||
|
|
84299eba92 | ||
|
|
cdf75ec505 | ||
|
|
22babda1c9 | ||
|
|
9f0c743afd | ||
|
|
4e92cd0254 | ||
|
|
d61ddda4ef | ||
|
|
10ecb36d16 | ||
|
|
205483e14c | ||
|
|
6584b545ea | ||
|
|
ac6592b7a5 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,9 +1,12 @@
|
|||||||
_site
|
_site
|
||||||
.gh-pages
|
.gh-pages
|
||||||
.idea
|
.idea
|
||||||
|
GeoLite2-City.mmdb
|
||||||
|
build
|
||||||
composer.lock
|
composer.lock
|
||||||
composer.phar
|
composer.phar
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
geoip2.phar
|
||||||
geoip2-php.sublime-*
|
geoip2-php.sublime-*
|
||||||
vendor/
|
vendor/
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ php:
|
|||||||
before_install:
|
before_install:
|
||||||
- composer self-update
|
- composer self-update
|
||||||
- composer install --dev -n --prefer-source
|
- composer install --dev -n --prefer-source
|
||||||
- if [ "hhvm" != "$(phpenv version-name)" ]; then pyrus install pear/PHP_CodeSniffer; fi
|
- if [ "5.5" == $TRAVIS_PHP_VERSION ]; then pyrus install pear/PHP_CodeSniffer; fi
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
- if [ "hhvm" != "$(phpenv version-name)" ]; then phpcs --standard=PSR2 src/; fi
|
- if [ "5.5" == $TRAVIS_PHP_VERSION ]; then phpcs --standard=PSR2 src/; fi
|
||||||
- phpunit -c phpunit.xml.dist
|
- phpunit -c phpunit.xml.dist
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
|
|||||||
43
CHANGELOG.md
43
CHANGELOG.md
@@ -1,6 +1,49 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.9.0 (2014-09-15)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* IMPORTANT: The deprecated `omni()` and `cityIspOrg()` methods have been
|
||||||
|
removed from `GeoIp2\WebService\Client`.
|
||||||
|
|
||||||
|
0.8.1 (2014-09-12)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* The check added to the `GeoIP2\Database\Reader` lookup methods in 0.8.0 did
|
||||||
|
not work with the GeoIP2 City Database Subset by Continent with World
|
||||||
|
Countries. This has been fixed. Fixes GitHub issue #23.
|
||||||
|
|
||||||
|
0.8.0 (2014-09-10)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* The `GeoIp2\Database\Reader` lookup methods (e.g., `city()`, `isp()`) now
|
||||||
|
throw a `BadMethodCallException` if they are used with a database that
|
||||||
|
does not match the method. In particular, doing a `city()` lookup on a
|
||||||
|
GeoIP2 Country database will result in an exception, and vice versa.
|
||||||
|
* A `metadata()` method has been added to the `GeoIP2\Database\Reader` class.
|
||||||
|
This returns a `MaxMind\Db\Reader\Metadata` class with information about the
|
||||||
|
database.
|
||||||
|
* The name attribute was missing from the RepresentedCountry class.
|
||||||
|
|
||||||
|
0.7.0 (2014-07-22)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* The web service client API has been updated for the v2.1 release of the web
|
||||||
|
service. In particular, the `cityIspOrg` and `omni` methods on
|
||||||
|
`GeoIp2\WebService\Client` should be considered deprecated. The `city`
|
||||||
|
method now provides all of the data formerly provided by `cityIspOrg`, and
|
||||||
|
the `omni` method has been replaced by the `insights` method.
|
||||||
|
* Support was added for GeoIP2 Connection Type, Domain and ISP databases.
|
||||||
|
|
||||||
|
|
||||||
|
0.6.3 (2014-05-12)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
* With the previous Phar builds, some users received `phar error: invalid url
|
||||||
|
or non-existent phar` errors. The correct alias is now used for the Phar,
|
||||||
|
and this should no longer be an issue.
|
||||||
|
|
||||||
0.6.2 (2014-05-08)
|
0.6.2 (2014-05-08)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
107
README.md
107
README.md
@@ -9,44 +9,40 @@ the free [GeoLite2 databases](http://dev.maxmind.com/geoip/geoip2/geolite2/).
|
|||||||
|
|
||||||
## Install via Composer ##
|
## Install via Composer ##
|
||||||
|
|
||||||
### Define Your Dependencies ###
|
|
||||||
|
|
||||||
We recommend installing this package with [Composer](http://getcomposer.org/).
|
We recommend installing this package with [Composer](http://getcomposer.org/).
|
||||||
To do this, add `geoip2/geoip2` to your `composer.json` file. If you don't
|
|
||||||
have a `composer.json` file, create one in the root directory of your project.
|
|
||||||
|
|
||||||
```json
|
### Download Composer ###
|
||||||
{
|
|
||||||
"require": {
|
To download Composer, run in the root directory of your project:
|
||||||
"geoip2/geoip2": "0.6.*"
|
|
||||||
}
|
```bash
|
||||||
}
|
curl -sS https://getcomposer.org/installer | php
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Composer ###
|
You should now have the file `composer.phar` in your project directory.
|
||||||
|
|
||||||
Run in your project root:
|
|
||||||
|
|
||||||
```
|
|
||||||
curl -s http://getcomposer.org/installer | php
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install Dependencies ###
|
### Install Dependencies ###
|
||||||
|
|
||||||
Run in your project root:
|
Run in your project root:
|
||||||
|
|
||||||
```
|
```
|
||||||
php composer.phar install
|
php composer.phar require geoip2/geoip2:~0.9.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You should now have the files `composer.json` and `composer.lock` as well as
|
||||||
|
the directory `vendor` in your project directory. If you use a version control
|
||||||
|
system, `composer.json` should be added to it.
|
||||||
|
|
||||||
### Require Autoloader ###
|
### Require Autoloader ###
|
||||||
|
|
||||||
You can autoload all dependencies by adding this to your code:
|
After installing the dependencies, you need to require the Composer autoloader
|
||||||
```
|
from your code:
|
||||||
|
|
||||||
|
```php
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installing via Phar ##
|
## Install via Phar ##
|
||||||
|
|
||||||
Although we strongly recommend using Composer, we also provide a
|
Although we strongly recommend using Composer, we also provide a
|
||||||
[phar archive](http://php.net/manual/en/book.phar.php) containing all of the
|
[phar archive](http://php.net/manual/en/book.phar.php) containing all of the
|
||||||
@@ -82,12 +78,12 @@ classes for the different parts of the data such as the city in which the
|
|||||||
IP address is located.
|
IP address is located.
|
||||||
|
|
||||||
If the record is not found, a `\GeoIp2\Exception\AddressNotFoundException`
|
If the record is not found, a `\GeoIp2\Exception\AddressNotFoundException`
|
||||||
is returned. If the database is invalid or corrupt, a
|
is thrown. If the database is invalid or corrupt, a
|
||||||
`\MaxMind\Db\InvalidDatabaseException` will be thrown.
|
`\MaxMind\Db\InvalidDatabaseException` will be thrown.
|
||||||
|
|
||||||
See the API documentation for more details.
|
See the API documentation for more details.
|
||||||
|
|
||||||
### Example ###
|
### City Example ###
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
@@ -118,6 +114,64 @@ print($record->location->longitude . "\n"); // -93.2323
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Connection-Type Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Connection-Type.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->connectionType('128.101.101.101');
|
||||||
|
|
||||||
|
print($record->connectionType . "\n"); // 'Corporate'
|
||||||
|
print($record->ipAddress . "\n"); // '128.101.101.101'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Domain Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Domain.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->domain('128.101.101.101');
|
||||||
|
|
||||||
|
print($record->domain . "\n"); // 'umn.edu'
|
||||||
|
print($record->ipAddress . "\n"); // '128.101.101.101'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### ISP Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-ISP.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->isp('128.101.101.101');
|
||||||
|
|
||||||
|
print($record->autonomousSystemNumber . "\n"); // 217
|
||||||
|
print($record->autonomousSystemOrganization . "\n"); // 'University of Minnesota'
|
||||||
|
print($record->isp . "\n"); // 'University of Minnesota'
|
||||||
|
print($record->organization . "\n"); // 'University of Minnesota'
|
||||||
|
|
||||||
|
print($record->ipAddress . "\n"); // '128.101.101.101'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Web Service Client ##
|
## Web Service Client ##
|
||||||
|
|
||||||
### Usage ###
|
### Usage ###
|
||||||
@@ -148,7 +202,7 @@ use GeoIp2\WebService\Client;
|
|||||||
$client = new Client(42, 'abcdef123456');
|
$client = new Client(42, 'abcdef123456');
|
||||||
|
|
||||||
// Replace "city" with the method corresponding to the web service that
|
// Replace "city" with the method corresponding to the web service that
|
||||||
// you are using, e.g., "country", "cityIspOrg", "omni".
|
// you are using, e.g., "country", "insights".
|
||||||
$record = $client->city('128.101.101.101');
|
$record = $client->city('128.101.101.101');
|
||||||
|
|
||||||
print($record->country->isoCode . "\n"); // 'US'
|
print($record->country->isoCode . "\n"); // 'US'
|
||||||
@@ -178,7 +232,7 @@ Because of these factors, it is possible for any end point to return a record
|
|||||||
where some or all of the attributes are unpopulated.
|
where some or all of the attributes are unpopulated.
|
||||||
|
|
||||||
See the
|
See the
|
||||||
[GeoIP2 web service docs](http://dev.maxmind.com/geoip/geoip2/web-services)
|
[GeoIP2 Precision web service docs](http://dev.maxmind.com/geoip/geoip2/web-services)
|
||||||
for details on what data each end point may return.
|
for details on what data each end point may return.
|
||||||
|
|
||||||
The only piece of data which is always returned is the `ipAddress`
|
The only piece of data which is always returned is the `ipAddress`
|
||||||
@@ -239,6 +293,9 @@ This library works and is tested with HHVM.
|
|||||||
This library also relies on the [Guzzle HTTP client](http://guzzlephp.org/)
|
This library also relies on the [Guzzle HTTP client](http://guzzlephp.org/)
|
||||||
and the [MaxMind DB Reader](https://github.com/maxmind/MaxMind-DB-Reader-php).
|
and the [MaxMind DB Reader](https://github.com/maxmind/MaxMind-DB-Reader-php).
|
||||||
|
|
||||||
|
If you are using PHP 5.3 with an autoloader besides Composer, you must load
|
||||||
|
`JsonSerializable.php` in the `compat` directory.
|
||||||
|
|
||||||
## Contributing ##
|
## Contributing ##
|
||||||
|
|
||||||
Patches and pull requests are encouraged. All code should follow the
|
Patches and pull requests are encouraged. All code should follow the
|
||||||
|
|||||||
26
bin/benchmark.php
Executable file
26
bin/benchmark.php
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../vendor/autoload.php';
|
||||||
|
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
use GeoIp2\Exception\AddressNotFoundException;
|
||||||
|
|
||||||
|
$reader = new Reader('GeoLite2-City.mmdb');
|
||||||
|
$count = 40000;
|
||||||
|
$startTime = microtime(true);
|
||||||
|
for ($i = 0; $i < $count; $i++) {
|
||||||
|
$ip = long2ip(rand(0, pow(2, 32) -1));
|
||||||
|
try {
|
||||||
|
$t = $reader->city($ip);
|
||||||
|
} catch (AddressNotFoundException $e) {
|
||||||
|
}
|
||||||
|
if ($i % 1000 == 0) {
|
||||||
|
print($i . ' ' . $ip . "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$endTime = microtime(true);
|
||||||
|
|
||||||
|
$duration = $endTime - $startTime;
|
||||||
|
print('Requests per second: ' . $count / $duration . "\n");
|
||||||
@@ -27,7 +27,7 @@ if [ -n "$(git status --porcelain)" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apigen --quiet --download --title "GeoIP2 PHP API $TAG" --source ../src --destination doc/$TAG
|
../vendor/bin/apigen --quiet --download --title "GeoIP2 PHP API $TAG" --source ../src --destination doc/$TAG
|
||||||
|
|
||||||
PAGE=index.md
|
PAGE=index.md
|
||||||
cat <<EOF > $PAGE
|
cat <<EOF > $PAGE
|
||||||
|
|||||||
1
box.json
1
box.json
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"alias": "geoip2.phar",
|
||||||
"main": "phar-stub.php",
|
"main": "phar-stub.php",
|
||||||
"output": "geoip2.phar",
|
"output": "geoip2.phar",
|
||||||
"compactors": [
|
"compactors": [
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"guzzle/guzzle": "3.*",
|
"guzzle/guzzle": "3.*",
|
||||||
"maxmind-db/reader": "~0.3.1",
|
"maxmind-db/reader": "~0.3.2",
|
||||||
"php": ">=5.3.1"
|
"php": ">=5.3.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.*",
|
"apigen/apigen": "~2.8.0",
|
||||||
|
"nette/nette": "~2.1.3",
|
||||||
|
"phpunit/phpunit": "4.1.*",
|
||||||
"satooshi/php-coveralls": "dev-master"
|
"satooshi/php-coveralls": "dev-master"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
Submodule maxmind-db updated: f887fec99e...1d28147617
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'phar://geoip2.phar/vendor/autoload.php';
|
||||||
|
|
||||||
// The following was taken from Guzzle (MIT license)
|
// The following was taken from Guzzle (MIT license)
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Reader implements ProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function city($ipAddress)
|
public function city($ipAddress)
|
||||||
{
|
{
|
||||||
return $this->modelFor('City', $ipAddress);
|
return $this->modelFor('City', 'City', $ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,55 +88,82 @@ class Reader implements ProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function country($ipAddress)
|
public function country($ipAddress)
|
||||||
{
|
{
|
||||||
return $this->modelFor('Country', $ipAddress);
|
return $this->modelFor('Country', 'Country', $ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function connectionType($ipAddress)
|
||||||
* This method returns a GeoIP2 City/ISP/Org model.
|
|
||||||
*
|
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string.
|
|
||||||
*
|
|
||||||
* @return \GeoIp2\Model\CityIspOrg
|
|
||||||
*
|
|
||||||
* @throws \GeoIp2\Exception\AddressNotFoundException if the address is
|
|
||||||
* not in the database.
|
|
||||||
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
|
|
||||||
* is corrupt or invalid
|
|
||||||
*/
|
|
||||||
public function cityIspOrg($ipAddress)
|
|
||||||
{
|
{
|
||||||
return $this->modelFor('CityIspOrg', $ipAddress);
|
return $this->flatModelFor(
|
||||||
|
'ConnectionType',
|
||||||
|
'GeoIP2-Connection-Type',
|
||||||
|
$ipAddress
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function domain($ipAddress)
|
||||||
* This method returns a GeoIP2 Omni model.
|
|
||||||
*
|
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string.
|
|
||||||
*
|
|
||||||
* @return \GeoIp2\Model\Omni
|
|
||||||
*
|
|
||||||
* @throws \GeoIp2\Exception\AddressNotFoundException if the address is
|
|
||||||
* not in the database.
|
|
||||||
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
|
|
||||||
* is corrupt or invalid
|
|
||||||
*/
|
|
||||||
public function omni($ipAddress)
|
|
||||||
{
|
{
|
||||||
return $this->modelFor('Omni', $ipAddress);
|
return $this->flatModelFor(
|
||||||
|
'Domain',
|
||||||
|
'GeoIP2-Domain',
|
||||||
|
$ipAddress
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function modelFor($class, $ipAddress)
|
public function isp($ipAddress)
|
||||||
{
|
{
|
||||||
|
return $this->flatModelFor(
|
||||||
|
'Isp',
|
||||||
|
'GeoIP2-ISP',
|
||||||
|
$ipAddress
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function modelFor($class, $type, $ipAddress)
|
||||||
|
{
|
||||||
|
$record = $this->getRecord($class, $type, $ipAddress);
|
||||||
|
|
||||||
|
$record['traits']['ip_address'] = $ipAddress;
|
||||||
|
$class = "GeoIp2\\Model\\" . $class;
|
||||||
|
|
||||||
|
return new $class($record, $this->locales);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function flatModelFor($class, $type, $ipAddress)
|
||||||
|
{
|
||||||
|
$record = $this->getRecord($class, $type, $ipAddress);
|
||||||
|
|
||||||
|
$record['ip_address'] = $ipAddress;
|
||||||
|
$class = "GeoIp2\\Model\\" . $class;
|
||||||
|
|
||||||
|
return new $class($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRecord($class, $type, $ipAddress)
|
||||||
|
{
|
||||||
|
if (strpos($this->metadata()->databaseType, $type) === false) {
|
||||||
|
$method = lcfirst($class);
|
||||||
|
throw new \BadMethodCallException(
|
||||||
|
"The $method method cannot be used to open a "
|
||||||
|
. $this->metadata()->databaseType . " database"
|
||||||
|
);
|
||||||
|
}
|
||||||
$record = $this->dbReader->get($ipAddress);
|
$record = $this->dbReader->get($ipAddress);
|
||||||
if ($record === null) {
|
if ($record === null) {
|
||||||
throw new AddressNotFoundException(
|
throw new AddressNotFoundException(
|
||||||
"The address $ipAddress is not in the database."
|
"The address $ipAddress is not in the database."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$record['traits']['ip_address'] = $ipAddress;
|
return $record;
|
||||||
$class = "GeoIp2\\Model\\" . $class;
|
}
|
||||||
|
|
||||||
return new $class($record, $this->locales);
|
/**
|
||||||
|
* @throws \InvalidArgumentException if arguments are passed to the method.
|
||||||
|
* @throws \BadMethodCallException if the database has been closed.
|
||||||
|
* @return \MaxMind\Db\Reader\Metadata object for the database.
|
||||||
|
*/
|
||||||
|
public function metadata()
|
||||||
|
{
|
||||||
|
return $this->dbReader->metadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
53
src/GeoIp2/Model/AbstractModel.php
Normal file
53
src/GeoIp2/Model/AbstractModel.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
abstract class AbstractModel implements \JsonSerializable
|
||||||
|
{
|
||||||
|
protected $raw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __construct($raw)
|
||||||
|
{
|
||||||
|
$this->raw = $raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
protected function get($field)
|
||||||
|
{
|
||||||
|
return isset($this->raw[$field]) ? $this->raw[$field] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __get($attr)
|
||||||
|
{
|
||||||
|
if ($attr != "instance" && property_exists($this, $attr)) {
|
||||||
|
return $this->$attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException("Unknown attribute: $attr");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __isset($attr)
|
||||||
|
{
|
||||||
|
return $attr != "instance" && isset($this->$attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->raw;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,11 +3,10 @@
|
|||||||
namespace GeoIp2\Model;
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a model for the data returned by the GeoIP2
|
* Model class for the data returned by GeoIP2 City web service and database.
|
||||||
* City end point.
|
|
||||||
*
|
*
|
||||||
* The only difference between the City, City/ISP/Org, and Omni model
|
* The only difference between the City and Insights model classes is which
|
||||||
* classes is which fields in each record may be populated. See
|
* fields in each record may be populated. See
|
||||||
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\City $city City data for the requested IP
|
* @property \GeoIp2\Record\City $city City data for the requested IP
|
||||||
@@ -33,8 +32,8 @@ namespace GeoIp2\Model;
|
|||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
||||||
* Represented country data for the requested IP address. The represented
|
* Represented country data for the requested IP address. The represented
|
||||||
* country is used for things like military bases or embassies. It is only
|
* country is used for things like military bases. It is only present when
|
||||||
* present when the represented country differs from the country.
|
* the represented country differs from the country.
|
||||||
*
|
*
|
||||||
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
|
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
|
||||||
* objects representing the country subdivisions for the requested IP
|
* objects representing the country subdivisions for the requested IP
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace GeoIp2\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides a model for the data returned by the GeoIP2
|
|
||||||
* City/ISP/Org end point.
|
|
||||||
*
|
|
||||||
* The only difference between the City, City/ISP/Org, and Omni model
|
|
||||||
* classes is which fields in each record may be populated. See
|
|
||||||
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\City $city City data for the requested IP
|
|
||||||
* address.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Continent $continent Continent data for the
|
|
||||||
* requested IP address.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Country $country Country data for the requested
|
|
||||||
* IP address. This object represents the country where MaxMind believes the
|
|
||||||
* end user is located.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Location $location Location data for the
|
|
||||||
* requested IP address.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
|
|
||||||
* account.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Country $registeredCountry Registered country
|
|
||||||
* data for the requested IP address. This record represents the country
|
|
||||||
* where the ISP has registered a given IP block and may differ from the
|
|
||||||
* user's country.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
|
||||||
* Represented country data for the requested IP address. The represented
|
|
||||||
* country is used for things like military bases or embassies. It is only
|
|
||||||
* present when the represented country differs from the country.
|
|
||||||
*
|
|
||||||
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
|
|
||||||
* objects representing the country subdivisions for the requested IP
|
|
||||||
* address. The number and type of subdivisions varies by country, but a
|
|
||||||
* subdivision is typically a state, province, county, etc. Subdivisions
|
|
||||||
* are ordered from most general (largest) to most specific (smallest).
|
|
||||||
* If the response did not contain any subdivisions, this method returns
|
|
||||||
* an empty array.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Subdivision $mostSpecificSubdivision An object
|
|
||||||
* representing the most specific subdivision returned. If the response
|
|
||||||
* did not contain any subdivisions, this method returns an empty
|
|
||||||
* {@link \GeoIp2\Record\Subdivision} object.
|
|
||||||
*
|
|
||||||
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
|
|
||||||
* requested IP address.
|
|
||||||
*/
|
|
||||||
class CityIspOrg extends City
|
|
||||||
{
|
|
||||||
}
|
|
||||||
31
src/GeoIp2/Model/ConnectionType.php
Normal file
31
src/GeoIp2/Model/ConnectionType.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides the GeoIP2 Connection-Type model.
|
||||||
|
*
|
||||||
|
* @property string $connectionType The connection type may take the following
|
||||||
|
* values: "Dialup", "Cable/DSL", "Corporate", "Cellular". Additional
|
||||||
|
* values may be added in the future.
|
||||||
|
*
|
||||||
|
* @property string $ipAddress The IP address that the data in the model is
|
||||||
|
* for.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ConnectionType extends AbstractModel
|
||||||
|
{
|
||||||
|
protected $connectionType;
|
||||||
|
protected $ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __construct($raw)
|
||||||
|
{
|
||||||
|
parent::__construct($raw);
|
||||||
|
|
||||||
|
$this->connectionType = $this->get('connection_type');
|
||||||
|
$this->ipAddress = $this->get('ip_address');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,11 +3,10 @@
|
|||||||
namespace GeoIp2\Model;
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a model for the data returned by the GeoIP2 Country
|
* Model class for the data returned by GeoIP2 Country web service and database.
|
||||||
* end point.
|
|
||||||
*
|
*
|
||||||
* The only difference between the City, City/ISP/Org, and Omni model
|
* The only difference between the City and Insights model classes is which
|
||||||
* classes is which fields in each record may be populated. See
|
* fields in each record may be populated. See
|
||||||
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\Continent $continent Continent data for the
|
* @property \GeoIp2\Record\Continent $continent Continent data for the
|
||||||
@@ -27,29 +26,28 @@ namespace GeoIp2\Model;
|
|||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
||||||
* Represented country data for the requested IP address. The represented
|
* Represented country data for the requested IP address. The represented
|
||||||
* country is used for things like military bases or embassies. It is only
|
* country is used for things like military bases. It is only present when
|
||||||
* present when the represented country differs from the country.
|
* the represented country differs from the country.
|
||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
|
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
|
||||||
* requested IP address.
|
* requested IP address.
|
||||||
*/
|
*/
|
||||||
class Country implements \JsonSerializable
|
class Country extends AbstractModel
|
||||||
{
|
{
|
||||||
private $continent;
|
protected $continent;
|
||||||
private $country;
|
protected $country;
|
||||||
private $locales;
|
protected $locales;
|
||||||
private $maxmind;
|
protected $maxmind;
|
||||||
private $registeredCountry;
|
protected $registeredCountry;
|
||||||
private $representedCountry;
|
protected $representedCountry;
|
||||||
private $traits;
|
protected $traits;
|
||||||
private $raw;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
public function __construct($raw, $locales = array('en'))
|
public function __construct($raw, $locales = array('en'))
|
||||||
{
|
{
|
||||||
$this->raw = $raw;
|
parent::__construct($raw);
|
||||||
|
|
||||||
$this->continent = new \GeoIp2\Record\Continent(
|
$this->continent = new \GeoIp2\Record\Continent(
|
||||||
$this->get('continent'),
|
$this->get('continent'),
|
||||||
@@ -72,37 +70,4 @@ class Country implements \JsonSerializable
|
|||||||
|
|
||||||
$this->locales = $locales;
|
$this->locales = $locales;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
protected function get($field)
|
|
||||||
{
|
|
||||||
return isset($this->raw[$field]) ? $this->raw[$field] : array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
public function __get($attr)
|
|
||||||
{
|
|
||||||
if ($attr != "instance" && isset($this->$attr)) {
|
|
||||||
return $this->$attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \RuntimeException("Unknown attribute: $attr");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
public function __isset($attr)
|
|
||||||
{
|
|
||||||
return $attr != "instance" && isset($this->$attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function jsonSerialize()
|
|
||||||
{
|
|
||||||
return $this->raw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/GeoIp2/Model/Domain.php
Normal file
31
src/GeoIp2/Model/Domain.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides the GeoIP2 Domain model.
|
||||||
|
*
|
||||||
|
* @property string $domain The second level domain associated with the IP
|
||||||
|
* address. This will be something like "example.com" or "example.co.uk",
|
||||||
|
* not "foo.example.com".
|
||||||
|
*
|
||||||
|
* @property string $ipAddress The IP address that the data in the model is
|
||||||
|
* for.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Domain extends AbstractModel
|
||||||
|
{
|
||||||
|
protected $domain;
|
||||||
|
protected $ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __construct($raw)
|
||||||
|
{
|
||||||
|
parent::__construct($raw);
|
||||||
|
|
||||||
|
$this->domain = $this->get('domain');
|
||||||
|
$this->ipAddress = $this->get('ip_address');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,11 +3,10 @@
|
|||||||
namespace GeoIp2\Model;
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a model for the data returned by the GeoIP2
|
* Model class for the data returned by GeoIP2 Precision: Insights web service.
|
||||||
* Omni end point.
|
|
||||||
*
|
*
|
||||||
* The only difference between the City, City/ISP/Org, and Omni model
|
* The only difference between the City and Insights model classes is which
|
||||||
* classes is which fields in each record may be populated. See
|
* fields in each record may be populated. See
|
||||||
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
* http://dev.maxmind.com/geoip/geoip2/web-services more details.
|
||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\City $city City data for the requested IP
|
* @property \GeoIp2\Record\City $city City data for the requested IP
|
||||||
@@ -33,8 +32,8 @@ namespace GeoIp2\Model;
|
|||||||
*
|
*
|
||||||
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
* @property \GeoIp2\Record\RepresentedCountry $representedCountry
|
||||||
* Represented country data for the requested IP address. The represented
|
* Represented country data for the requested IP address. The represented
|
||||||
* country is used for things like military bases or embassies. It is only
|
* country is used for things like military bases. It is only present when
|
||||||
* present when the represented country differs from the country.
|
* the represented country differs from the country.
|
||||||
*
|
*
|
||||||
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
|
* @property array $subdivisions An array of {@link \GeoIp2\Record\Subdivision}
|
||||||
* objects representing the country subdivisions for the requested IP
|
* objects representing the country subdivisions for the requested IP
|
||||||
@@ -52,6 +51,6 @@ namespace GeoIp2\Model;
|
|||||||
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
|
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
|
||||||
* requested IP address.
|
* requested IP address.
|
||||||
*/
|
*/
|
||||||
class Omni extends CityIspOrg
|
class Insights extends City
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
45
src/GeoIp2/Model/Isp.php
Normal file
45
src/GeoIp2/Model/Isp.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GeoIp2\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides the GeoIP2 Connection-Type model.
|
||||||
|
*
|
||||||
|
* @property integer $autonomousSystemNumber The autonomous system number
|
||||||
|
* associated with the IP address.
|
||||||
|
*
|
||||||
|
* @property string $autonomousSystemOrganization The organization associated
|
||||||
|
* with the registered autonomous system number for the IP address.
|
||||||
|
*
|
||||||
|
* @property string $isp The name of the ISP associated with the IP address.
|
||||||
|
*
|
||||||
|
* @property string $organization The name of the organization associated with
|
||||||
|
* the IP address.
|
||||||
|
*
|
||||||
|
* @property string $ipAddress The IP address that the data in the model is
|
||||||
|
* for.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Isp extends AbstractModel
|
||||||
|
{
|
||||||
|
protected $autonomousSystemNumber;
|
||||||
|
protected $autonomousSystemOrganization;
|
||||||
|
protected $isp;
|
||||||
|
protected $organization;
|
||||||
|
protected $ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
public function __construct($raw)
|
||||||
|
{
|
||||||
|
parent::__construct($raw);
|
||||||
|
$this->autonomousSystemNumber = $this->get('autonomous_system_number');
|
||||||
|
$this->autonomousSystemOrganization =
|
||||||
|
$this->get('autonomous_system_organization');
|
||||||
|
$this->isp = $this->get('isp');
|
||||||
|
$this->organization = $this->get('organization');
|
||||||
|
|
||||||
|
$this->ipAddress = $this->get('ip_address');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,18 +17,4 @@ interface ProviderInterface
|
|||||||
* @return \GeoIp2\Model\City A City model for the requested IP address.
|
* @return \GeoIp2\Model\City A City model for the requested IP address.
|
||||||
*/
|
*/
|
||||||
public function city($ipAddress);
|
public function city($ipAddress);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ipAddress
|
|
||||||
* IPv4 or IPv6 address to lookup.
|
|
||||||
* @return \GeoIp2\Model\CityIspOrg A CityIspOrg model for the requested IP address.
|
|
||||||
*/
|
|
||||||
public function cityIspOrg($ipAddress);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ipAddress
|
|
||||||
* IPv4 or IPv6 address to lookup.
|
|
||||||
* @return \GeoIp2\Model\Omni An Omni model for the requested IP address.
|
|
||||||
*/
|
|
||||||
public function omni($ipAddress);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ abstract class AbstractRecord implements \JsonSerializable
|
|||||||
*/
|
*/
|
||||||
public function __construct($record)
|
public function __construct($record)
|
||||||
{
|
{
|
||||||
$this->record = $record;
|
$this->record = isset($record) ? $record : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace GeoIp2\Record;
|
|||||||
*
|
*
|
||||||
* @property int $confidence A value from 0-100 indicating MaxMind's
|
* @property int $confidence A value from 0-100 indicating MaxMind's
|
||||||
* confidence that the city is correct. This attribute is only available
|
* confidence that the city is correct. This attribute is only available
|
||||||
* from the Omni end point.
|
* from the Insights end point.
|
||||||
*
|
*
|
||||||
* @property int $geonameId The GeoName ID for the city. This attribute
|
* @property int $geonameId The GeoName ID for the city. This attribute
|
||||||
* is returned by all end points.
|
* is returned by all end points.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace GeoIp2\Record;
|
|||||||
*
|
*
|
||||||
* @property int $accuracyRadius The radius in kilometers around the
|
* @property int $accuracyRadius The radius in kilometers around the
|
||||||
* specified location where the IP address is likely to be. This attribute
|
* specified location where the IP address is likely to be. This attribute
|
||||||
* is only available from the Omni end point.
|
* is only available from the Insights end point.
|
||||||
*
|
*
|
||||||
* @property float $latitude The latitude of the location as a floating
|
* @property float $latitude The latitude of the location as a floating
|
||||||
* point number. This attribute is returned by all end points except the
|
* point number. This attribute is returned by all end points except the
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace GeoIp2\Record;
|
|||||||
*
|
*
|
||||||
* @property int $confidence A value from 0-100 indicating MaxMind's
|
* @property int $confidence A value from 0-100 indicating MaxMind's
|
||||||
* confidence that the postal code is correct. This attribute is only
|
* confidence that the postal code is correct. This attribute is only
|
||||||
* available from the Omni end point.
|
* available from the Insights end point.
|
||||||
*/
|
*/
|
||||||
class Postal extends AbstractRecord
|
class Postal extends AbstractRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,31 +7,26 @@ namespace GeoIp2\Record;
|
|||||||
*
|
*
|
||||||
* This class contains the country-level data associated with an IP address
|
* This class contains the country-level data associated with an IP address
|
||||||
* for the IP's represented country. The represented country is the country
|
* for the IP's represented country. The represented country is the country
|
||||||
* represented by something like a military base or embassy.
|
* represented by something like a military base.
|
||||||
*
|
|
||||||
* This record is returned by all the end points.
|
|
||||||
*
|
*
|
||||||
* @property int $confidence A value from 0-100 indicating MaxMind's
|
* @property int $confidence A value from 0-100 indicating MaxMind's
|
||||||
* confidence that the country is correct. This attribute is only available
|
* confidence that the country is correct. This attribute is only available
|
||||||
* from the Omni end point.
|
* from the Insights end point.
|
||||||
*
|
*
|
||||||
* @property int $geonameId The GeoName ID for the country. This attribute is
|
* @property int $geonameId The GeoName ID for the country.
|
||||||
* returned by all end points.
|
|
||||||
*
|
*
|
||||||
* @property string $isoCode The {@link http://en.wikipedia.org/wiki/ISO_3166-1
|
* @property string $isoCode The {@link http://en.wikipedia.org/wiki/ISO_3166-1
|
||||||
* two-character ISO 3166-1 alpha code} for the country. This attribute is
|
* two-character ISO 3166-1 alpha code} for the country.
|
||||||
* returned by all end points.
|
|
||||||
*
|
*
|
||||||
* @property string $name The name of the country based on the locales list
|
* @property string $name The name of the country based on the locales list
|
||||||
* passed to the constructor. This attribute is returned by all end points.
|
* passed to the constructor.
|
||||||
*
|
*
|
||||||
* @property array $names An array map where the keys are locale codes and
|
* @property array $names An array map where the keys are locale codes and
|
||||||
* the values are names. This attribute is returned by all end points.
|
* the values are names.
|
||||||
*
|
*
|
||||||
* @property string $type A string indicating the type of entity that is
|
* @property string $type A string indicating the type of entity that is
|
||||||
* representing the country. Currently we only return <code>military</code>
|
* representing the country. Currently we only return <code>military</code>
|
||||||
* but this could expand to include other types such as <code>embassy</code>
|
* but this could expand to include other types in the future.
|
||||||
* in the future. Returned by all endpoints.
|
|
||||||
*/
|
*/
|
||||||
class RepresentedCountry extends Country
|
class RepresentedCountry extends Country
|
||||||
{
|
{
|
||||||
@@ -39,7 +34,7 @@ class RepresentedCountry extends Country
|
|||||||
'confidence',
|
'confidence',
|
||||||
'geonameId',
|
'geonameId',
|
||||||
'isoCode',
|
'isoCode',
|
||||||
'namespace',
|
'names',
|
||||||
'type'
|
'type'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace GeoIp2\Record;
|
|||||||
*
|
*
|
||||||
* @property int $confidence This is a value from 0-100 indicating MaxMind's
|
* @property int $confidence This is a value from 0-100 indicating MaxMind's
|
||||||
* confidence that the subdivision is correct. This attribute is only
|
* confidence that the subdivision is correct. This attribute is only
|
||||||
* available from the Omni end point.
|
* available from the Insights end point.
|
||||||
*
|
*
|
||||||
* @property int $geonameId This is a GeoName ID for the subdivision. This
|
* @property int $geonameId This is a GeoName ID for the subdivision. This
|
||||||
* attribute is returned by all end points except Country.
|
* attribute is returned by all end points except Country.
|
||||||
|
|||||||
@@ -11,18 +11,18 @@ namespace GeoIp2\Record;
|
|||||||
* @property int $autonomousSystemNumber The {@link
|
* @property int $autonomousSystemNumber The {@link
|
||||||
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
|
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
|
||||||
* system number} associated with the IP address. This attribute is only
|
* system number} associated with the IP address. This attribute is only
|
||||||
* available from the City/ISP/Org and Omni end points.
|
* available from the City and Insights web service end points.
|
||||||
*
|
*
|
||||||
* @property string $autonomousSystemOrganization The organization
|
* @property string $autonomousSystemOrganization The organization
|
||||||
* associated with the registered {@link
|
* associated with the registered {@link
|
||||||
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
|
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
|
||||||
* system number} for the IP address. This attribute is only available from
|
* system number} for the IP address. This attribute is only available from
|
||||||
* the City/ISP/Org and Omni end points.
|
* the City and Insights web service end points.
|
||||||
*
|
*
|
||||||
* @property string $domain The second level domain associated with the
|
* @property string $domain The second level domain associated with the
|
||||||
* IP address. This will be something like "example.com" or "example.co.uk",
|
* IP address. This will be something like "example.com" or "example.co.uk",
|
||||||
* not "foo.example.com". This attribute is only available from the
|
* not "foo.example.com". This attribute is only available from the
|
||||||
* City/ISP/Org and Omni end points.
|
* City and Insights web service end points.
|
||||||
*
|
*
|
||||||
* @property string $ipAddress The IP address that the data in the model
|
* @property string $ipAddress The IP address that the data in the model
|
||||||
* is for. If you performed a "me" lookup against the web service, this
|
* is for. If you performed a "me" lookup against the web service, this
|
||||||
@@ -40,12 +40,12 @@ namespace GeoIp2\Record;
|
|||||||
* end points.
|
* end points.
|
||||||
*
|
*
|
||||||
* @property string $isp The name of the ISP associated with the IP address.
|
* @property string $isp The name of the ISP associated with the IP address.
|
||||||
* This attribute is only available from the City/ISP/Org and Omni end
|
* This attribute is only available from the City and Insights web service end
|
||||||
* points.
|
* points.
|
||||||
*
|
*
|
||||||
* @property string $organization The name of the organization associated
|
* @property string $organization The name of the organization associated
|
||||||
* with the IP address. This attribute is only available from the City/ISP/Org
|
* with the IP address. This attribute is only available from the City and
|
||||||
* and Omni end points.
|
* Insights web service end points.
|
||||||
*
|
*
|
||||||
* @property string $userType <p>The user type associated with the IP
|
* @property string $userType <p>The user type associated with the IP
|
||||||
* address. This can be one of the following values:</p>
|
* address. This can be one of the following values:</p>
|
||||||
@@ -66,7 +66,10 @@ namespace GeoIp2\Record;
|
|||||||
* <li>search_engine_spider
|
* <li>search_engine_spider
|
||||||
* <li>traveler
|
* <li>traveler
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>This attribute is only available from the Omni end point.</p>
|
* <p>
|
||||||
|
* This attribute is only available from the Insights web service end
|
||||||
|
* point.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
class Traits extends AbstractRecord
|
class Traits extends AbstractRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ use Guzzle\Http\Exception\ClientErrorResponseException;
|
|||||||
use Guzzle\Http\Exception\ServerErrorResponseException;
|
use Guzzle\Http\Exception\ServerErrorResponseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a client API for all the GeoIP2 web service's
|
* This class provides a client API for all the GeoIP2 Precision web service
|
||||||
* end points. The end points are Country, City, City/ISP/Org, and Omni. Each
|
* end points. The end points are Country, City, and Insights. Each end point
|
||||||
* end point returns a different set of data about an IP address, with Country
|
* returns a different set of data about an IP address, with Country returning
|
||||||
* returning the least data and Omni the most.
|
* the least data and Insights the most.
|
||||||
*
|
*
|
||||||
* Each web service end point is represented by a different model class, and
|
* Each web service end point is represented by a different model class, and
|
||||||
* these model classes in turn contain multiple Record classes. The record
|
* these model classes in turn contain multiple Record classes. The record
|
||||||
@@ -80,7 +80,7 @@ class Client implements ProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the GeoIP2 City endpoint.
|
* This method calls the GeoIP2 Precision: City endpoint.
|
||||||
*
|
*
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
||||||
* address is provided, the address that the web service is called
|
* address is provided, the address that the web service is called
|
||||||
@@ -112,7 +112,7 @@ class Client implements ProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the GeoIP2 Country endpoint.
|
* This method calls the GeoIP2 Precision: Country endpoint.
|
||||||
*
|
*
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
||||||
* address is provided, the address that the web service is called
|
* address is provided, the address that the web service is called
|
||||||
@@ -144,13 +144,13 @@ class Client implements ProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calls the GeoIP2 City/ISP/Org endpoint.
|
* This method calls the GeoIP2 Precision: Insights endpoint.
|
||||||
*
|
*
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
||||||
* address is provided, the address that the web service is called
|
* address is provided, the address that the web service is called
|
||||||
* from will be used.
|
* from will be used.
|
||||||
*
|
*
|
||||||
* @return \GeoIp2\Model\CityIspOrg
|
* @return \GeoIp2\Model\Insights
|
||||||
*
|
*
|
||||||
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
|
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
|
||||||
* provided is not in our database (e.g., a private address).
|
* provided is not in our database (e.g., a private address).
|
||||||
@@ -170,41 +170,9 @@ class Client implements ProviderInterface
|
|||||||
* class to the above exceptions. It will be thrown directly if a 200
|
* class to the above exceptions. It will be thrown directly if a 200
|
||||||
* status code is returned but the body is invalid.
|
* status code is returned but the body is invalid.
|
||||||
*/
|
*/
|
||||||
public function cityIspOrg($ipAddress = 'me')
|
public function insights($ipAddress = 'me')
|
||||||
{
|
{
|
||||||
return $this->responseFor('city_isp_org', 'CityIspOrg', $ipAddress);
|
return $this->responseFor('insights', 'Insights', $ipAddress);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method calls the GeoIP2 Omni endpoint.
|
|
||||||
*
|
|
||||||
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
|
|
||||||
* address is provided, the address that the web service is called
|
|
||||||
* from will be used.
|
|
||||||
*
|
|
||||||
* @return \GeoIp2\Model\Omni
|
|
||||||
*
|
|
||||||
* @throws \GeoIp2\Exception\AddressNotFoundException if the address you
|
|
||||||
* provided is not in our database (e.g., a private address).
|
|
||||||
* @throws \GeoIp2\Exception\AuthenticationException if there is a problem
|
|
||||||
* with the user ID or license key that you provided.
|
|
||||||
* @throws \GeoIp2\Exception\OutOfQueriesException if your account is out
|
|
||||||
* of queries.
|
|
||||||
* @throws \GeoIp2\Exception\InvalidRequestException} if your request was
|
|
||||||
* received by the web service but is invalid for some other reason.
|
|
||||||
* This may indicate an issue with this API. Please report the error to
|
|
||||||
* MaxMind.
|
|
||||||
* @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
|
|
||||||
* code or message was returned. This could indicate a problem with the
|
|
||||||
* connection between your server and the web service or that the web
|
|
||||||
* service returned an invalid document or 500 error code.
|
|
||||||
* @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
|
|
||||||
* class to the above exceptions. It will be thrown directly if a 200
|
|
||||||
* status code is returned but the body is invalid.
|
|
||||||
*/
|
|
||||||
public function omni($ipAddress = 'me')
|
|
||||||
{
|
|
||||||
return $this->responseFor('omni', 'Omni', $ipAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function responseFor($endpoint, $class, $ipAddress)
|
private function responseFor($endpoint, $class, $ipAddress)
|
||||||
@@ -354,6 +322,6 @@ class Client implements ProviderInterface
|
|||||||
|
|
||||||
private function baseUri()
|
private function baseUri()
|
||||||
{
|
{
|
||||||
return 'https://' . $this->host . '/geoip/v2.0';
|
return 'https://' . $this->host . '/geoip/v2.1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,44 +8,39 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
public function testDefaultLocale()
|
public function testDefaultLocale()
|
||||||
{
|
{
|
||||||
$reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb');
|
foreach (array('City', 'Country') as $type) {
|
||||||
// Needed for PHP 5.3
|
$reader = new Reader("maxmind-db/test-data/GeoIP2-$type-Test.mmdb");
|
||||||
$that = $this;
|
$method = lcfirst($type);
|
||||||
$this->checkAllMethods(
|
$record = $reader->$method('81.2.69.160');
|
||||||
function ($method) use (&$that, &$reader) {
|
$this->assertEquals('United Kingdom', $record->country->name);
|
||||||
$record = $reader->$method('81.2.69.160');
|
}
|
||||||
$that->assertEquals('United Kingdom', $record->country->name);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$reader->close();
|
$reader->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocaleList()
|
public function testLocaleList()
|
||||||
{
|
{
|
||||||
$reader = new Reader(
|
|
||||||
'maxmind-db/test-data/GeoIP2-City-Test.mmdb',
|
foreach (array('City', 'Country') as $type) {
|
||||||
array('xx', 'ru', 'pt-BR', 'es', 'en')
|
$reader = new Reader(
|
||||||
);
|
"maxmind-db/test-data/GeoIP2-$type-Test.mmdb",
|
||||||
$that = $this;
|
array('xx', 'ru', 'pt-BR', 'es', 'en')
|
||||||
$this->checkAllMethods(
|
);
|
||||||
function ($method) use (&$that, &$reader) {
|
$method = lcfirst($type);
|
||||||
$record = $reader->$method('81.2.69.160');
|
|
||||||
$that->assertEquals('Великобритания', $record->country->name);
|
$record = $reader->$method('81.2.69.160');
|
||||||
}
|
$this->assertEquals('Великобритания', $record->country->name);
|
||||||
);
|
}
|
||||||
$reader->close();
|
$reader->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHasIpAddress()
|
public function testHasIpAddress()
|
||||||
{
|
{
|
||||||
$reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb');
|
foreach (array('City', 'Country') as $type) {
|
||||||
$that = $this;
|
$reader = new Reader("maxmind-db/test-data/GeoIP2-$type-Test.mmdb");
|
||||||
$this->checkAllMethods(
|
$method = lcfirst($type);
|
||||||
function ($method) use (&$that, &$reader) {
|
$record = $reader->$method('81.2.69.160');
|
||||||
$record = $reader->$method('81.2.69.160');
|
$this->assertEquals('81.2.69.160', $record->traits->ipAddress);
|
||||||
$that->assertEquals('81.2.69.160', $record->traits->ipAddress);
|
}
|
||||||
}
|
|
||||||
);
|
|
||||||
$reader->close();
|
$reader->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +55,28 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$reader->close();
|
$reader->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException BadMethodCallException
|
||||||
|
* @expectedExceptionMessage The country method cannot be used to open a GeoIP2-City database
|
||||||
|
*/
|
||||||
|
public function testIncorrectDatabase()
|
||||||
|
{
|
||||||
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb');
|
||||||
|
$reader->country('10.10.10.10');
|
||||||
|
$reader->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException BadMethodCallException
|
||||||
|
* @expectedExceptionMessage The domain method cannot be used to open a GeoIP2-City database
|
||||||
|
*/
|
||||||
|
public function testIncorrectDatabaseFlat()
|
||||||
|
{
|
||||||
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb');
|
||||||
|
$reader->domain('10.10.10.10');
|
||||||
|
$reader->close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException InvalidArgumentException
|
||||||
* @expectedExceptionMessage is not a valid IP address
|
* @expectedExceptionMessage is not a valid IP address
|
||||||
@@ -71,10 +88,53 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$reader->close();
|
$reader->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkAllMethods($testCb)
|
|
||||||
|
public function testConnectionType()
|
||||||
{
|
{
|
||||||
foreach (array('city', 'cityIspOrg', 'country', 'omni') as $method) {
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-Connection-Type-Test.mmdb');
|
||||||
$testCb($method);
|
$ipAddress = '1.0.1.0';
|
||||||
}
|
|
||||||
|
$record = $reader->connectionType($ipAddress);
|
||||||
|
$this->assertEquals('Cable/DSL', $record->connectionType);
|
||||||
|
$this->assertEquals($ipAddress, $record->ipAddress);
|
||||||
|
$reader->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDomain()
|
||||||
|
{
|
||||||
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-Domain-Test.mmdb');
|
||||||
|
|
||||||
|
$ipAddress = '1.2.0.0';
|
||||||
|
$record = $reader->domain($ipAddress);
|
||||||
|
$this->assertEquals('maxmind.com', $record->domain);
|
||||||
|
$this->assertEquals($ipAddress, $record->ipAddress);
|
||||||
|
$reader->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIsp()
|
||||||
|
{
|
||||||
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-ISP-Test.mmdb');
|
||||||
|
|
||||||
|
$ipAddress = '1.128.0.0';
|
||||||
|
$record = $reader->isp($ipAddress);
|
||||||
|
$this->assertEquals(1221, $record->autonomousSystemNumber);
|
||||||
|
$this->assertEquals(
|
||||||
|
'Telstra Pty Ltd',
|
||||||
|
$record->autonomousSystemOrganization
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals('Telstra Internet', $record->isp);
|
||||||
|
$this->assertEquals('Telstra Internet', $record->organization);
|
||||||
|
|
||||||
|
$this->assertEquals($ipAddress, $record->ipAddress);
|
||||||
|
$reader->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMetadata()
|
||||||
|
{
|
||||||
|
$reader = new Reader('maxmind-db/test-data/GeoIP2-City-Test.mmdb');
|
||||||
|
$this->assertEquals('GeoIP2-City', $reader->metadata()->databaseType);
|
||||||
|
|
||||||
|
$reader->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace GeoIp2\Test\Model;
|
namespace GeoIp2\Test\Model;
|
||||||
|
|
||||||
use GeoIp2\Model\Omni;
|
use GeoIp2\Model\Insights;
|
||||||
|
|
||||||
class OmniTest extends \PHPUnit_Framework_TestCase
|
class InsightsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testFull()
|
public function testFull()
|
||||||
@@ -69,12 +69,12 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$model = new Omni($raw, array('en'));
|
$model = new Insights($raw, array('en'));
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'GeoIp2\Model\Omni',
|
'GeoIp2\Model\Insights',
|
||||||
$model,
|
$model,
|
||||||
'GeoIp2\Model\Omni object'
|
'GeoIp2\Model\Insights object'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
@@ -147,12 +147,12 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$raw = array('traits' => array('ip_address' => '5.6.7.8'));
|
$raw = array('traits' => array('ip_address' => '5.6.7.8'));
|
||||||
|
|
||||||
$model = new Omni($raw, array('en'));
|
$model = new Insights($raw, array('en'));
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'GeoIp2\Model\Omni',
|
'GeoIp2\Model\Insights',
|
||||||
$model,
|
$model,
|
||||||
'GeoIp2\Model\Omni object with no data except traits.ipAddress'
|
'GeoIp2\Model\Insights object with no data except traits.ipAddress'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
@@ -231,12 +231,12 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
// checking whether there are exceptions with unknown keys
|
// checking whether there are exceptions with unknown keys
|
||||||
$model = new Omni($raw, array('en'));
|
$model = new Insights($raw, array('en'));
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'GeoIp2\Model\Omni',
|
'GeoIp2\Model\Insights',
|
||||||
$model,
|
$model,
|
||||||
'no exception when Omni model gets raw data with unknown keys'
|
'no exception when Insights model gets raw data with unknown keys'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@@ -198,16 +198,17 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testOmni()
|
public function testInsights()
|
||||||
{
|
{
|
||||||
$omni = $this->client($this->getResponse('1.2.3.4'))
|
|
||||||
->omni('1.2.3.4');
|
|
||||||
|
|
||||||
$this->assertInstanceOf('GeoIp2\Model\Omni', $omni);
|
$record = $this->client($this->getResponse('1.2.3.4'))
|
||||||
|
->insights('1.2.3.4');
|
||||||
|
|
||||||
|
$this->assertInstanceOf('GeoIp2\Model\Insights', $record);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
42,
|
42,
|
||||||
$omni->continent->geonameId,
|
$record->continent->geonameId,
|
||||||
'continent geoname_id is 42'
|
'continent geoname_id is 42'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -225,15 +226,15 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$client = $this->client($this->getResponse('me'));
|
$client = $this->client($this->getResponse('me'));
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'GeoIp2\Model\CityIspOrg',
|
'GeoIp2\Model\City',
|
||||||
$client->cityIspOrg('me'),
|
$client->city('me'),
|
||||||
'can set ip parameter to me'
|
'can set ip parameter to me'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException GeoIp2\Exception\GeoIp2Exception
|
* @expectedException GeoIp2\Exception\GeoIp2Exception
|
||||||
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.5 but did not receive a HTTP body.
|
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.5 but did not receive a HTTP body.
|
||||||
*/
|
*/
|
||||||
public function testNoBodyException()
|
public function testNoBodyException()
|
||||||
{
|
{
|
||||||
@@ -244,7 +245,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException GeoIp2\Exception\GeoIp2Exception
|
* @expectedException GeoIp2\Exception\GeoIp2Exception
|
||||||
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/2.2.3.5 but could not decode the response as JSON:
|
* @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.1/country/2.2.3.5 but could not decode the response as JSON:
|
||||||
*/
|
*/
|
||||||
public function testBadBodyException()
|
public function testBadBodyException()
|
||||||
{
|
{
|
||||||
@@ -332,7 +333,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @expectedException GeoIp2\Exception\HttpException
|
* @expectedException GeoIp2\Exception\HttpException
|
||||||
* @expectedExceptionCode 406
|
* @expectedExceptionCode 406
|
||||||
* @expectedExceptionMessage Received a 406 error for https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.12 with the following body: Cannot satisfy your Accept-Charset requirements
|
* @expectedExceptionMessage Received a 406 error for https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.12 with the following body: Cannot satisfy your Accept-Charset requirements
|
||||||
*/
|
*/
|
||||||
public function test406Exception()
|
public function test406Exception()
|
||||||
{
|
{
|
||||||
@@ -426,7 +427,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$request = $all_requests[0];
|
$request = $all_requests[0];
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.4',
|
'https://geoip.maxmind.com/geoip/v2.1/country/1.2.3.4',
|
||||||
$request->getUrl(),
|
$request->getUrl(),
|
||||||
'got expected URI for Country request'
|
'got expected URI for Country request'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user