Tidying and doc fixes
This commit is contained in:
parent
234dcaff7c
commit
e03b9558a9
|
@ -14,7 +14,7 @@ use MaxMind\Db\Reader as DbReader;
|
||||||
* client, although we may offer the ability to specify additional databases
|
* client, although we may offer the ability to specify additional databases
|
||||||
* to replicate these web services in the future (e.g., the ISP/Org database).
|
* to replicate these web services in the future (e.g., the ISP/Org database).
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
* The basic API for this class is the same for every database. First, you
|
* The basic API for this class is the same for every database. First, you
|
||||||
* create a reader object, specifying a file name. You then call the method
|
* create a reader object, specifying a file name. You then call the method
|
||||||
|
@ -44,7 +44,7 @@ class Reader implements ProviderInterface
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $filename The path to the GeoIP2 database file.
|
* @param string $filename The path to the GeoIP2 database file.
|
||||||
* @param array $locales List of locale codes to use in name property
|
* @param array $locales List of locale codes to use in name property
|
||||||
* from most preferred to least preferred.
|
* from most preferred to least preferred.
|
||||||
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
|
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
|
||||||
* is corrupt or invalid
|
* is corrupt or invalid
|
||||||
|
|
|
@ -17,7 +17,7 @@ class HttpException extends GeoIp2Exception
|
||||||
$message,
|
$message,
|
||||||
$httpStatus,
|
$httpStatus,
|
||||||
$uri,
|
$uri,
|
||||||
Exception $previous = null
|
\Exception $previous = null
|
||||||
) {
|
) {
|
||||||
$this->uri = $uri;
|
$this->uri = $uri;
|
||||||
parent::__construct($message, $httpStatus, $previous);
|
parent::__construct($message, $httpStatus, $previous);
|
||||||
|
|
|
@ -18,7 +18,7 @@ class InvalidRequestException extends HttpException
|
||||||
$error,
|
$error,
|
||||||
$httpStatus,
|
$httpStatus,
|
||||||
$uri,
|
$uri,
|
||||||
Exception $previous = null
|
\Exception $previous = null
|
||||||
) {
|
) {
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
parent::__construct($message, $httpStatus, $uri, $previous);
|
parent::__construct($message, $httpStatus, $uri, $previous);
|
||||||
|
|
|
@ -113,8 +113,8 @@ class City extends Country
|
||||||
|
|
||||||
private function mostSpecificSubdivision()
|
private function mostSpecificSubdivision()
|
||||||
{
|
{
|
||||||
return empty($this->subdivisions)?
|
return empty($this->subdivisions) ?
|
||||||
new \GeoIp2\Record\Subdivision(array(), $this->locales):
|
new \GeoIp2\Record\Subdivision(array(), $this->locales) :
|
||||||
end($this->subdivisions);
|
end($this->subdivisions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Country
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
public function __get ($attr)
|
public function __get($attr)
|
||||||
{
|
{
|
||||||
if ($attr != "instance" && isset($this->$attr)) {
|
if ($attr != "instance" && isset($this->$attr)) {
|
||||||
return $this->$attr;
|
return $this->$attr;
|
||||||
|
|
|
@ -7,28 +7,28 @@ interface ProviderInterface
|
||||||
/**
|
/**
|
||||||
* @param ipAddress
|
* @param ipAddress
|
||||||
* IPv4 or IPv6 address to lookup.
|
* IPv4 or IPv6 address to lookup.
|
||||||
* @return A Country model for the requested IP address.
|
* @return \GeoIp2\Model\Country A Country model for the requested IP address.
|
||||||
*/
|
*/
|
||||||
public function country($ipAddress);
|
public function country($ipAddress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ipAddress
|
* @param ipAddress
|
||||||
* IPv4 or IPv6 address to lookup.
|
* IPv4 or IPv6 address to lookup.
|
||||||
* @return 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
|
* @param ipAddress
|
||||||
* IPv4 or IPv6 address to lookup.
|
* IPv4 or IPv6 address to lookup.
|
||||||
* @return A CityIspOrg model for the requested IP address.
|
* @return \GeoIp2\Model\CityIspOrg A CityIspOrg model for the requested IP address.
|
||||||
*/
|
*/
|
||||||
public function cityIspOrg($ipAddress);
|
public function cityIspOrg($ipAddress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ipAddress
|
* @param ipAddress
|
||||||
* IPv4 or IPv6 address to lookup.
|
* IPv4 or IPv6 address to lookup.
|
||||||
* @return An Omni model for the requested IP address.
|
* @return \GeoIp2\Model\Omni An Omni model for the requested IP address.
|
||||||
*/
|
*/
|
||||||
public function omni($ipAddress);
|
public function omni($ipAddress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace GeoIp2\Record;
|
||||||
* @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 except
|
* the values are names. This attribute is returned by all end points except
|
||||||
* Country.
|
* Country.
|
||||||
*/
|
*/
|
||||||
class Subdivision extends AbstractPlaceRecord
|
class Subdivision extends AbstractPlaceRecord
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
namespace GeoIp2\WebService;
|
namespace GeoIp2\WebService;
|
||||||
|
|
||||||
use GeoIp2\Exception\GeoIp2Exception;
|
|
||||||
use GeoIp2\Exception\HttpException;
|
|
||||||
use GeoIp2\Exception\AddressNotFoundException;
|
use GeoIp2\Exception\AddressNotFoundException;
|
||||||
use GeoIp2\Exception\AuthenticationException;
|
use GeoIp2\Exception\AuthenticationException;
|
||||||
|
use GeoIp2\Exception\GeoIp2Exception;
|
||||||
|
use GeoIp2\Exception\HttpException;
|
||||||
use GeoIp2\Exception\InvalidRequestException;
|
use GeoIp2\Exception\InvalidRequestException;
|
||||||
use GeoIp2\Exception\OutOfQueriesException;
|
use GeoIp2\Exception\OutOfQueriesException;
|
||||||
use GeoIp2\ProviderInterface;
|
use GeoIp2\ProviderInterface;
|
||||||
use Guzzle\Http\Client as GuzzleClient;
|
|
||||||
use Guzzle\Common\Exception\RuntimeException;
|
use Guzzle\Common\Exception\RuntimeException;
|
||||||
|
use Guzzle\Http\Client as GuzzleClient;
|
||||||
use Guzzle\Http\Exception\ClientErrorResponseException;
|
use Guzzle\Http\Exception\ClientErrorResponseException;
|
||||||
use Guzzle\Http\Exception\ServerErrorResponseException;
|
use Guzzle\Http\Exception\ServerErrorResponseException;
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ class Client implements ProviderInterface
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param int $userId Your MaxMind user ID
|
* @param int $userId Your MaxMind user ID
|
||||||
* @param string $licenseKey Your MaxMind license key
|
* @param string $licenseKey Your MaxMind license key
|
||||||
* @param array $locales List of locale codes to use in name property
|
* @param array $locales List of locale codes to use in name property
|
||||||
* from most preferred to least preferred.
|
* from most preferred to least preferred.
|
||||||
* @param string $host Optional host parameter
|
* @param string $host Optional host parameter
|
||||||
* @param object $guzzleClient Optional Guzzle client to use (to facilitate
|
* @param object $guzzleClient Optional Guzzle client to use (to facilitate
|
||||||
|
@ -258,8 +258,6 @@ class Client implements ProviderInterface
|
||||||
{
|
{
|
||||||
$status = $response->getStatusCode();
|
$status = $response->getStatusCode();
|
||||||
|
|
||||||
$body = array();
|
|
||||||
|
|
||||||
if ($response->getContentLength() > 0) {
|
if ($response->getContentLength() > 0) {
|
||||||
if (strstr($response->getContentType(), 'json')) {
|
if (strstr($response->getContentType(), 'json')) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -9,19 +9,19 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
private $raw = array(
|
private $raw = array(
|
||||||
'continent' => array(
|
'continent' => array(
|
||||||
'code' => 'NA',
|
'code' => 'NA',
|
||||||
'geoname_id' => 42,
|
'geoname_id' => 42,
|
||||||
'names' => array( 'en' => 'North America' ),
|
'names' => array('en' => 'North America'),
|
||||||
),
|
),
|
||||||
'country' => array(
|
'country' => array(
|
||||||
'geoname_id' => 1,
|
'geoname_id' => 1,
|
||||||
'iso_code' => 'US',
|
'iso_code' => 'US',
|
||||||
'names' => array( 'en' => 'United States of America' ),
|
'names' => array('en' => 'United States of America'),
|
||||||
),
|
),
|
||||||
'registered_country' => array(
|
'registered_country' => array(
|
||||||
'geoname_id' => 2,
|
'geoname_id' => 2,
|
||||||
'iso_code' => 'CA',
|
'iso_code' => 'CA',
|
||||||
'names' => array( 'en' => 'Canada' ),
|
'names' => array('en' => 'Canada'),
|
||||||
),
|
),
|
||||||
'traits' => array(
|
'traits' => array(
|
||||||
'ip_address' => '1.2.3.4',
|
'ip_address' => '1.2.3.4',
|
||||||
|
@ -30,12 +30,12 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
private $model;
|
private $model;
|
||||||
|
|
||||||
public function setUp ()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->model = new Country($this->raw, array('en'));
|
$this->model = new Country($this->raw, array('en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjects ()
|
public function testObjects()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
'GeoIp2\Model\Country',
|
'GeoIp2\Model\Country',
|
||||||
|
@ -80,7 +80,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array( 'en' => 'North America' ),
|
array('en' => 'North America'),
|
||||||
$this->model->continent->names,
|
$this->model->continent->names,
|
||||||
'continent names'
|
'continent names'
|
||||||
);
|
);
|
||||||
|
@ -104,7 +104,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array( 'en' => 'United States of America' ),
|
array('en' => 'United States of America'),
|
||||||
$this->model->country->names,
|
$this->model->country->names,
|
||||||
'country name'
|
'country name'
|
||||||
);
|
);
|
||||||
|
@ -134,7 +134,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array( 'en' => 'Canada' ),
|
array('en' => 'Canada'),
|
||||||
$this->model->registeredCountry->names,
|
$this->model->registeredCountry->names,
|
||||||
'registered_country names'
|
'registered_country names'
|
||||||
);
|
);
|
||||||
|
@ -145,7 +145,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase
|
||||||
'registered_country name is Canada'
|
'registered_country name is Canada'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (array( 'isAnonymousProxy', 'isSatelliteProvider' ) as $meth) {
|
foreach (array('isAnonymousProxy', 'isSatelliteProvider') as $meth) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
0,
|
0,
|
||||||
$this->model->traits->$meth,
|
$this->model->traits->$meth,
|
||||||
|
|
|
@ -7,31 +7,31 @@ use GeoIp2\Model\Country;
|
||||||
class NameTest extends \PHPUnit_Framework_TestCase
|
class NameTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public $raw = array(
|
public $raw = array(
|
||||||
'continent' => array(
|
'continent' => array(
|
||||||
'code' => 'NA',
|
'code' => 'NA',
|
||||||
'geoname_id' => 42,
|
'geoname_id' => 42,
|
||||||
'names' => array(
|
'names' => array(
|
||||||
'en' => 'North America',
|
'en' => 'North America',
|
||||||
'zh-CN' => '北美洲',
|
'zh-CN' => '北美洲',
|
||||||
),
|
|
||||||
),
|
),
|
||||||
'country' => array(
|
),
|
||||||
'geoname_id' => 1,
|
'country' => array(
|
||||||
'iso_code' => 'US',
|
'geoname_id' => 1,
|
||||||
'names' => array(
|
'iso_code' => 'US',
|
||||||
'en' => 'United States of America',
|
'names' => array(
|
||||||
'ru' => 'объединяет государства',
|
'en' => 'United States of America',
|
||||||
'zh-CN' => '美国',
|
'ru' => 'объединяет государства',
|
||||||
),
|
'zh-CN' => '美国',
|
||||||
),
|
),
|
||||||
'traits' => array(
|
),
|
||||||
'ip_address' => '1.2.3.4',
|
'traits' => array(
|
||||||
),
|
'ip_address' => '1.2.3.4',
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
public function testFallback()
|
public function testFallback()
|
||||||
{
|
{
|
||||||
$model = new Country($this->raw, array( 'ru', 'zh-CN', 'en' ));
|
$model = new Country($this->raw, array('ru', 'zh-CN', 'en'));
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'北美洲',
|
'北美洲',
|
||||||
|
|
|
@ -14,58 +14,58 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
||||||
'city' => array(
|
'city' => array(
|
||||||
'confidence' => 76,
|
'confidence' => 76,
|
||||||
'geoname_id' => 9876,
|
'geoname_id' => 9876,
|
||||||
'names' => array( 'en' => 'Minneapolis' ),
|
'names' => array('en' => 'Minneapolis'),
|
||||||
),
|
),
|
||||||
'continent' => array(
|
'continent' => array(
|
||||||
'code' => 'NA',
|
'code' => 'NA',
|
||||||
'geoname_id' => 42,
|
'geoname_id' => 42,
|
||||||
'names' => array( 'en' => 'North America' ),
|
'names' => array('en' => 'North America'),
|
||||||
),
|
),
|
||||||
'country' => array(
|
'country' => array(
|
||||||
'confidence' => 99,
|
'confidence' => 99,
|
||||||
'geoname_id' => 1,
|
'geoname_id' => 1,
|
||||||
'iso_code' => 'US',
|
'iso_code' => 'US',
|
||||||
'names' => array( 'en' => 'United States of America' ),
|
'names' => array('en' => 'United States of America'),
|
||||||
),
|
),
|
||||||
'location' => array(
|
'location' => array(
|
||||||
'accuracy_radius' => 1500,
|
'accuracy_radius' => 1500,
|
||||||
'latitude' => 44.98,
|
'latitude' => 44.98,
|
||||||
'longitude' => 93.2636,
|
'longitude' => 93.2636,
|
||||||
'metro_code' => 765,
|
'metro_code' => 765,
|
||||||
'postal_code' => '55401',
|
'postal_code' => '55401',
|
||||||
'postal_confidence' => 33,
|
'postal_confidence' => 33,
|
||||||
'time_zone' => 'America/Chicago',
|
'time_zone' => 'America/Chicago',
|
||||||
),
|
),
|
||||||
'maxmind' => array(
|
'maxmind' => array(
|
||||||
'queries_remaining' => 22,
|
'queries_remaining' => 22,
|
||||||
),
|
),
|
||||||
'registered_country' => array(
|
'registered_country' => array(
|
||||||
'geoname_id' => 2,
|
'geoname_id' => 2,
|
||||||
'iso_code' => 'CA',
|
'iso_code' => 'CA',
|
||||||
'names' => array( 'en' => 'Canada' ),
|
'names' => array('en' => 'Canada'),
|
||||||
),
|
),
|
||||||
'represented_country' => array(
|
'represented_country' => array(
|
||||||
'geoname_id' => 3,
|
'geoname_id' => 3,
|
||||||
'iso_code' => 'GB',
|
'iso_code' => 'GB',
|
||||||
'names' => array( 'en' => 'United Kingdom' ),
|
'names' => array('en' => 'United Kingdom'),
|
||||||
),
|
),
|
||||||
'subdivisions' => array(
|
'subdivisions' => array(
|
||||||
array(
|
array(
|
||||||
'confidence' => 88,
|
'confidence' => 88,
|
||||||
'geoname_id' => 574635,
|
'geoname_id' => 574635,
|
||||||
'iso_code' => 'MN',
|
'iso_code' => 'MN',
|
||||||
'names' => array( 'en' => 'Minnesota' ),
|
'names' => array('en' => 'Minnesota'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'traits' => array(
|
'traits' => array(
|
||||||
'autonomous_system_number' => 1234,
|
'autonomous_system_number' => 1234,
|
||||||
'autonomous_system_organization' => 'AS Organization',
|
'autonomous_system_organization' => 'AS Organization',
|
||||||
'domain' => 'example.com',
|
'domain' => 'example.com',
|
||||||
'ip_address' => '1.2.3.4',
|
'ip_address' => '1.2.3.4',
|
||||||
'is_satellite_provider' => 1,
|
'is_satellite_provider' => 1,
|
||||||
'isp' => 'Comcast',
|
'isp' => 'Comcast',
|
||||||
'organization' => 'Blorg',
|
'organization' => 'Blorg',
|
||||||
'user_type' => 'college',
|
'user_type' => 'college',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testEmptyObjects()
|
public function testEmptyObjects()
|
||||||
{
|
{
|
||||||
$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 Omni($raw, array('en'));
|
||||||
|
|
||||||
|
@ -220,14 +220,14 @@ class OmniTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testUnknown()
|
public function testUnknown()
|
||||||
{
|
{
|
||||||
$raw = array(
|
$raw = array(
|
||||||
'new_top_level' => array( 'foo' => 42 ),
|
'new_top_level' => array('foo' => 42),
|
||||||
'city' => array(
|
'city' => array(
|
||||||
'confidence' => 76,
|
'confidence' => 76,
|
||||||
'geoname_id_id' => 9876,
|
'geoname_id_id' => 9876,
|
||||||
'names' => array( 'en' => 'Minneapolis' ),
|
'names' => array('en' => 'Minneapolis'),
|
||||||
'population' => 50,
|
'population' => 50,
|
||||||
),
|
),
|
||||||
'traits' => array( 'ip_address' => '5.6.7.8' )
|
'traits' => array('ip_address' => '5.6.7.8')
|
||||||
);
|
);
|
||||||
|
|
||||||
// checking whether there are exceptions with unknown keys
|
// checking whether there are exceptions with unknown keys
|
||||||
|
|
|
@ -13,14 +13,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
private $country
|
private $country
|
||||||
= array(
|
= array(
|
||||||
'continent' => array(
|
'continent' => array(
|
||||||
'code' => 'NA',
|
'code' => 'NA',
|
||||||
'geoname_id' => 42,
|
'geoname_id' => 42,
|
||||||
'names' => array( 'en' => 'North America' ),
|
'names' => array('en' => 'North America'),
|
||||||
),
|
),
|
||||||
'country' => array(
|
'country' => array(
|
||||||
'geoname_id' => 1,
|
'geoname_id' => 1,
|
||||||
'iso_code' => 'US',
|
'iso_code' => 'US',
|
||||||
'names' => array( 'en' => 'United States of America' ),
|
'names' => array('en' => 'United States of America'),
|
||||||
),
|
),
|
||||||
'maxmind' => array('queries_remaining' => 11),
|
'maxmind' => array('queries_remaining' => 11),
|
||||||
'traits' => array(
|
'traits' => array(
|
||||||
|
@ -44,11 +44,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
),
|
),
|
||||||
'1.2.3.5' => $this->response('country', 200),
|
'1.2.3.5' => $this->response('country', 200),
|
||||||
'2.2.3.5' => $this->response('country', 200, 'bad body'),
|
'2.2.3.5' => $this->response('country', 200, 'bad body'),
|
||||||
'1.2.3.6'=> $this->response(
|
'1.2.3.6' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
400,
|
400,
|
||||||
array(
|
array(
|
||||||
'code' => 'IP_ADDRESS_INVALID',
|
'code' => 'IP_ADDRESS_INVALID',
|
||||||
'error' => 'The value "1.2.3" is not a valid ip address'
|
'error' => 'The value "1.2.3" is not a valid ip address'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -59,7 +59,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
'1.2.3.8' => $this->response(
|
'1.2.3.8' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
400,
|
400,
|
||||||
array( 'weird' => 42 )
|
array('weird' => 42)
|
||||||
),
|
),
|
||||||
'1.2.3.9' => $this->response(
|
'1.2.3.9' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
|
@ -82,51 +82,51 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
null,
|
null,
|
||||||
'text/plain'
|
'text/plain'
|
||||||
),
|
),
|
||||||
'1.2.3.13'=> $this->response(
|
'1.2.3.13' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
404,
|
404,
|
||||||
array(
|
array(
|
||||||
'code' => 'IP_ADDRESS_NOT_FOUND',
|
'code' => 'IP_ADDRESS_NOT_FOUND',
|
||||||
'error' => 'The address "1.2.3.13" is not in our database.'
|
'error' => 'The address "1.2.3.13" is not in our database.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1.2.3.14'=> $this->response(
|
'1.2.3.14' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
400,
|
400,
|
||||||
array(
|
array(
|
||||||
'code' => 'IP_ADDRESS_RESERVED',
|
'code' => 'IP_ADDRESS_RESERVED',
|
||||||
'error' => 'The address "1.2.3.14" is a private address.'
|
'error' => 'The address "1.2.3.14" is a private address.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1.2.3.15'=> $this->response(
|
'1.2.3.15' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
401,
|
401,
|
||||||
array(
|
array(
|
||||||
'code' => 'AUTHORIZATION_INVALID',
|
'code' => 'AUTHORIZATION_INVALID',
|
||||||
'error' => 'A user ID and license key are required to use this service'
|
'error' => 'A user ID and license key are required to use this service'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1.2.3.16'=> $this->response(
|
'1.2.3.16' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
401,
|
401,
|
||||||
array(
|
array(
|
||||||
'code' => 'LICENSE_KEY_REQUIRED',
|
'code' => 'LICENSE_KEY_REQUIRED',
|
||||||
'error' => 'A license key is required to use this service'
|
'error' => 'A license key is required to use this service'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1.2.3.17'=> $this->response(
|
'1.2.3.17' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
401,
|
401,
|
||||||
array(
|
array(
|
||||||
'code' => 'USER_ID_REQUIRED',
|
'code' => 'USER_ID_REQUIRED',
|
||||||
'error' => 'A user ID is required to use this service'
|
'error' => 'A user ID is required to use this service'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1.2.3.18'=> $this->response(
|
'1.2.3.18' => $this->response(
|
||||||
'error',
|
'error',
|
||||||
402,
|
402,
|
||||||
array(
|
array(
|
||||||
'code' => 'OUT_OF_QUERIES',
|
'code' => 'OUT_OF_QUERIES',
|
||||||
'error' => 'The license key you have provided is out of queries.'
|
'error' => 'The license key you have provided is out of queries.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -178,7 +178,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array( 'en' => 'United States of America' ),
|
array('en' => 'United States of America'),
|
||||||
$country->country->names,
|
$country->country->names,
|
||||||
'country names'
|
'country names'
|
||||||
);
|
);
|
||||||
|
@ -478,7 +478,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
$headers = array();
|
$headers = array();
|
||||||
if ($contentType) {
|
if ($contentType) {
|
||||||
$headers['Content-Type'] = $contentType;
|
$headers['Content-Type'] = $contentType;
|
||||||
} elseif ($status == 200 || ( $status >= 400 && $status < 500 )) {
|
} elseif ($status == 200 || ($status >= 400 && $status < 500)) {
|
||||||
$headers['Content-Type'] = 'application/vnd.maxmind.com-'
|
$headers['Content-Type'] = 'application/vnd.maxmind.com-'
|
||||||
. $endpoint . '+json; charset=UTF-8; version=1.0;';
|
. $endpoint . '+json; charset=UTF-8; version=1.0;';
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||||
if ($bad) {
|
if ($bad) {
|
||||||
$body = '{ invalid: }';
|
$body = '{ invalid: }';
|
||||||
} elseif (is_array($body)) {
|
} elseif (is_array($body)) {
|
||||||
$body = json_encode($body);
|
$body = json_encode($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers['Content-Length'] = strlen($body);
|
$headers['Content-Length'] = strlen($body);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
|
if (!$loader = @include __DIR__ . '/../vendor/autoload.php') {
|
||||||
die('Project dependencies missing');
|
die('Project dependencies missing');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user