Rename GeoIP2 => GeoIp2 for consistency

This commit is contained in:
Gregory Oschwald 2013-07-10 15:24:40 -07:00
parent 1c37dcac03
commit e60181f13a
28 changed files with 179 additions and 177 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ _site
composer.lock
composer.phar
phpunit.xml
geoip2-php.sublime-*
vendor/
*.sw?
t.php

View File

@ -20,7 +20,7 @@ In the future, this distribution will also provide the same API for the
GeoIP2 downloadable databases. These databases have not yet been
released as a downloadable product.
See ``GeoIP2\WebService\Client`` for details on the web service client
See ``GeoIp2\WebService\Client`` for details on the web service client
API.
## Installation ##
@ -63,7 +63,7 @@ require 'vendor/autoload.php';
## Usage ##
To use this API, you must create a new ``\GeoIP2\WebService\Client``
To use this API, you must create a new ``\GeoIp2\WebService\Client``
object with your ``$userId`` and ``$licenseKey``, then you call the method
corresponding to a specific end point, passing it the IP address you want to
look up.
@ -79,7 +79,7 @@ See the API documentation for more details.
```php
<?php
require_once 'vendor/autoload.php';
use \GeoIP2\WebService\Client;
use \GeoIp2\WebService\Client;
$client = new Client(42, 'abcdef123456');
$omni = $client->omni('24.24.24.24');
@ -93,18 +93,18 @@ the
[GeoIP2 web service docs](http://dev.maxmind.com/geoip2/geoip/web-service).
If the web service returns an explicit error document, this is thrown as a
```\GeoIP2\Exception\WebServiceException```. If some other sort of transport
error occurs, this is thrown as a ```\GeoIP2\Exception\HttpException```.
```\GeoIp2\Exception\WebServiceException```. If some other sort of transport
error occurs, this is thrown as a ```\GeoIp2\Exception\HttpException```.
The difference is that the web service error includes an error message and
error code delivered by the web service. The latter is thrown when some sort
of unanticipated error occurs, such as the web service returning a 500 or an
invalid error document.
If the web service returns any status code besides 200, 4xx, or 5xx, this also
becomes a ```\GeoIP2\Exception\HttpException```.
becomes a ```\GeoIp2\Exception\HttpException```.
Finally, if the web service returns a 200 but the body is invalid, the client
throws a ```\GeoIP2\Exception\GeoIP2Exception```.
throws a ```\GeoIp2\Exception\GeoIp2Exception```.
## What data is returned? ##
@ -121,7 +121,7 @@ See the
for details on what data each end point may return.
The only piece of data which is always returned is the ```ipAddress```
attribute in the ``GeoIP2\Record\Traits`` record.
attribute in the ``GeoIp2\Record\Traits`` record.
Every record class attribute has a corresponding predicate method so you can
check to see if the attribute is set.

View File

@ -3,13 +3,13 @@
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="GeoIP2 Test Suite">
<directory suffix="Test.php">./tests/GeoIP2/Test/</directory>
<directory suffix="Test.php">./tests/GeoIp2/Test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/GeoIP2/</directory>
<directory suffix=".php">./src/GeoIp2/</directory>
</whitelist>
</filter>

View File

@ -1,10 +0,0 @@
<?php
namespace GeoIP2\Exception;
/**
* This class represents a generic error.
*/
class GeoIP2Exception extends \Exception
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace GeoIp2\Exception;
/**
* This class represents a generic error.
*/
class GeoIp2Exception extends \Exception
{
}

View File

@ -1,12 +1,12 @@
<?php
namespace GeoIP2\Exception;
namespace GeoIp2\Exception;
/**
* This class represents an HTTP transport error.
*/
class HttpException extends GeoIP2Exception
class HttpException extends GeoIp2Exception
{
/**
* The URI queried

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Exception;
namespace GeoIp2\Exception;
/**
* This class represents an error returned by MaxMind's GeoIP2

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
@ -10,33 +10,33 @@ namespace GeoIP2\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
* @property \GeoIp2\Record\City $city City data for the requested IP
* address.
*
* @property \GeoIP2\Record\Continent $continent Continent data for the
* @property \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
*
* @property \GeoIP2\Record\Country $country Country data for the requested
* @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
* @property \GeoIp2\Record\Location $location Location data for the
* requested IP address.
*
* @property \GeoIP2\Record\MaxMind $maxmind Data related to your MaxMind
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
* account.
*
* @property \GeoIP2\Record\Country $registeredCountry Registered country
* @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
* @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}
* @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
@ -44,12 +44,12 @@ namespace GeoIP2\Model;
* If the response did not contain any subdivisions, this method returns
* an empty array.
*
* @property \GeoIP2\Record\Subdivision $mostSpecificSubdivision An object
* @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.
* {@link \GeoIp2\Record\Subdivision} object.
*
* @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.
*/
class City extends Country
@ -78,9 +78,9 @@ class City extends Country
{
parent::__construct($raw, $languages);
$this->city = new \GeoIP2\Record\City($this->get('city'), $languages);
$this->location = new \GeoIP2\Record\Location($this->get('location'));
$this->postal = new \GeoIP2\Record\Postal($this->get('postal'));
$this->city = new \GeoIp2\Record\City($this->get('city'), $languages);
$this->location = new \GeoIp2\Record\Location($this->get('location'));
$this->postal = new \GeoIp2\Record\Postal($this->get('postal'));
$this->createSubdivisions($raw, $languages);
}
@ -94,7 +94,7 @@ class City extends Country
foreach ($raw['subdivisions'] as $sub) {
array_push(
$this->subdivisions,
new \GeoIP2\Record\Subdivision($sub, $languages)
new \GeoIp2\Record\Subdivision($sub, $languages)
);
}
}
@ -114,7 +114,7 @@ class City extends Country
private function mostSpecificSubdivision()
{
return empty($this->subdivisions)?
new \GeoIP2\Record\Subdivision(array(), $this->languages):
new \GeoIp2\Record\Subdivision(array(), $this->languages):
end($this->subdivisions);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
@ -10,33 +10,33 @@ namespace GeoIP2\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
* @property \GeoIp2\Record\City $city City data for the requested IP
* address.
*
* @property \GeoIP2\Record\Continent $continent Continent data for the
* @property \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
*
* @property \GeoIP2\Record\Country $country Country data for the requested
* @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
* @property \GeoIp2\Record\Location $location Location data for the
* requested IP address.
*
* @property \GeoIP2\Record\MaxMind $maxmind Data related to your MaxMind
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
* account.
*
* @property \GeoIP2\Record\Country $registeredCountry Registered country
* @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
* @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}
* @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
@ -44,12 +44,12 @@ namespace GeoIP2\Model;
* If the response did not contain any subdivisions, this method returns
* an empty array.
*
* @property \GeoIP2\Record\Subdivision $mostSpecificSubdivision An object
* @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.
* {@link \GeoIp2\Record\Subdivision} object.
*
* @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.
*/
class CityIspOrg extends City

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2 Country
@ -10,27 +10,27 @@ namespace GeoIP2\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\Continent $continent Continent data for the
* @property \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
*
* @property \GeoIP2\Record\Country $country Country data for the requested
* @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\MaxMind $maxmind Data related to your MaxMind
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
* account.
*
* @property \GeoIP2\Record\Country $registeredCountry Registered country
* @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
* @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 \GeoIP2\Record\Traits $traits Data for the traits of the
* @property \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
*/
class Country
@ -51,24 +51,24 @@ class Country
{
$this->raw = $raw;
$this->continent = new \GeoIP2\Record\Continent(
$this->continent = new \GeoIp2\Record\Continent(
$this->get('continent'),
$languages
);
$this->country = new \GeoIP2\Record\Country(
$this->country = new \GeoIp2\Record\Country(
$this->get('country'),
$languages
);
$this->maxmind = new \GeoIP2\Record\MaxMind($this->get('maxmind'));
$this->registeredCountry = new \GeoIP2\Record\Country(
$this->maxmind = new \GeoIp2\Record\MaxMind($this->get('maxmind'));
$this->registeredCountry = new \GeoIp2\Record\Country(
$this->get('registered_country'),
$languages
);
$this->representedCountry = new \GeoIP2\Record\RepresentedCountry(
$this->representedCountry = new \GeoIp2\Record\RepresentedCountry(
$this->get('represented_country'),
$languages
);
$this->traits = new \GeoIP2\Record\Traits($this->get('traits'));
$this->traits = new \GeoIp2\Record\Traits($this->get('traits'));
$this->languages = $languages;
}

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2
@ -10,33 +10,33 @@ namespace GeoIP2\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
* @property \GeoIp2\Record\City $city City data for the requested IP
* address.
*
* @property \GeoIP2\Record\Continent $continent Continent data for the
* @property \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
*
* @property \GeoIP2\Record\Country $country Country data for the requested
* @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
* @property \GeoIp2\Record\Location $location Location data for the
* requested IP address.
*
* @property \GeoIP2\Record\MaxMind $maxmind Data related to your MaxMind
* @property \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
* account.
*
* @property \GeoIP2\Record\Country $registeredCountry Registered country
* @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
* @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}
* @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
@ -44,12 +44,12 @@ namespace GeoIP2\Model;
* If the response did not contain any subdivisions, this method returns
* an empty array.
*
* @property \GeoIP2\Record\Subdivision $mostSpecificSubdivision An object
* @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.
* {@link \GeoIp2\Record\Subdivision} object.
*
* @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.
*/
class Omni extends CityIspOrg

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
abstract class AbstractPlaceRecord extends AbstractRecord
{

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
abstract class AbstractRecord
{

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* City-level data associated with an IP address.

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the continent record associated with an IP address

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the country record associated with an IP address

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the location record associated with an IP address

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data about your account.

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the postal record associated with an IP address

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the represented country associated with an IP address

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
*

View File

@ -1,6 +1,6 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
*

View File

@ -1,21 +1,21 @@
<?php
namespace GeoIP2\WebService;
namespace GeoIp2\WebService;
use GeoIP2\Exception\GeoIP2Exception;
use GeoIP2\Exception\HttpException;
use GeoIP2\Exception\WebServiceException;
use GeoIP2\Model\City;
use GeoIP2\Model\CityIspOrg;
use GeoIP2\Model\Country;
use GeoIP2\Model\Omni;
use GeoIp2\Exception\GeoIp2Exception;
use GeoIp2\Exception\HttpException;
use GeoIp2\Exception\WebServiceException;
use GeoIp2\Model\City;
use GeoIp2\Model\CityIspOrg;
use GeoIp2\Model\Country;
use GeoIp2\Model\Omni;
use Guzzle\Http\Client as GuzzleClient;
use Guzzle\Common\Exception\RuntimeException;
use Guzzle\Http\Exception\ClientErrorResponseException;
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 web service's
* end points. The end points are Country, City, City/ISP/Org, and Omni. Each
* end point returns a different set of data about an IP address, with Country
* returning the least data and Omni the most.
@ -52,18 +52,18 @@ use Guzzle\Http\Exception\ServerErrorResponseException;
* service docs}.
*
* If the web service returns an explicit error document, this is thrown as a
* {@link \GeoIP2\Exception\WebServiceException}. If some other sort of
* {@link \GeoIp2\Exception\WebServiceException}. If some other sort of
* transport error occurs, this is thrown as a {@link
* \GeoIP2\Exception\HttpException}. The difference is that the web service
* \GeoIp2\Exception\HttpException}. The difference is that the web service
* error includes an error message and error code delivered by the web
* service. The latter is thrown when some sort of unanticipated error occurs,
* such as the web service returning a 500 or an invalid error document.
*
* If the web service returns any status code besides 200, 4xx, or 5xx, this
* also becomes a {@link \GeoIP2\Exception\HttpException}.
* also becomes a {@link \GeoIp2\Exception\HttpException}.
*
* Finally, if the web service returns a 200 but the body is invalid, the
* client throws a {@link \GeoIP2\Exception\GeoIP2Exception}.
* client throws a {@link \GeoIp2\Exception\GeoIp2Exception}.
*/
class Client
{
@ -106,14 +106,14 @@ class Client
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIP2\Model\City
* @return \GeoIp2\Model\City
*
* @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic
* @throws \GeoIp2\Exception\GeoIp2Exception if there was a generic
* error processing your request.
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
* @throws \GeoIp2\Exception\HttpException if there was an HTTP transport
* error.
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIp2 web service.
*/
public function city($ipAddress = 'me')
{
@ -127,14 +127,14 @@ class Client
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIP2\Model\Country
* @return \GeoIp2\Model\Country
*
* @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic
* @throws \GeoIp2\Exception\GeoIp2Exception if there was a generic
* error processing your request.
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
* @throws \GeoIp2\Exception\HttpException if there was an HTTP transport
* error.
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIp2 web service.
*/
public function country($ipAddress = 'me')
{
@ -148,14 +148,14 @@ class Client
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIP2\Model\CityIspOrg
* @return \GeoIp2\Model\CityIspOrg
*
* @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic
* @throws \GeoIp2\Exception\GeoIp2Exception if there was a generic
* error processing your request.
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
* @throws \GeoIp2\Exception\HttpException if there was an HTTP transport
* error.
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIp2 web service.
*/
public function cityIspOrg($ipAddress = 'me')
{
@ -169,14 +169,14 @@ class Client
* address is provided, the address that the web service is called
* from will be used.
*
* @return \GeoIP2\Model\Omni
* @return \GeoIp2\Model\Omni
*
* @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic
* @throws \GeoIp2\Exception\GeoIp2Exception if there was a generic
* error processing your request.
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
* @throws \GeoIp2\Exception\HttpException if there was an HTTP transport
* error.
* @throws \GeoIP2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIp2 web service.
*/
public function omni($ipAddress = 'me')
{
@ -206,7 +206,7 @@ class Client
if ($response && $response->isSuccessful()) {
$body = $this->handleSuccess($response, $uri);
$class = "GeoIP2\\Model\\" . $class;
$class = "GeoIp2\\Model\\" . $class;
return new $class($body, $this->languages);
} else {
$this->handleNon200($response, $uri);
@ -216,7 +216,7 @@ class Client
private function handleSuccess($response, $uri)
{
if ($response->getContentLength() == 0) {
throw new GeoIP2Exception(
throw new GeoIp2Exception(
"Received a 200 response for $uri but did not " .
"receive a HTTP body."
);
@ -225,7 +225,7 @@ class Client
try {
return $response->json();
} catch (RuntimeException $e) {
throw new GeoIP2Exception(
throw new GeoIp2Exception(
"Received a 200 response for $uri but could not decode " .
"the response as JSON: " . $e->getMessage()
);
@ -244,7 +244,7 @@ class Client
try {
$body = $response->json();
if (!isset($body['code']) || !isset($body['error'])) {
throw new GeoIP2Exception(
throw new GeoIp2Exception(
'Response contains JSON but it does not specify ' .
'code or error keys: ' . $response->getBody()
);

View File

@ -1,8 +1,8 @@
<?php
namespace GeoIP2\Test\Model;
namespace GeoIp2\Test\Model;
use GeoIP2\Model\Country;
use GeoIp2\Model\Country;
class CountryTest extends \PHPUnit_Framework_TestCase
{
@ -38,28 +38,28 @@ class CountryTest extends \PHPUnit_Framework_TestCase
public function testObjects ()
{
$this->assertInstanceOf(
'GeoIP2\Model\Country',
'GeoIp2\Model\Country',
$this->model,
'minimal GeoIP2::Model::Country object'
'minimal GeoIp2::Model::Country object'
);
$this->assertInstanceOf(
'GeoIP2\Record\Continent',
'GeoIp2\Record\Continent',
$this->model->continent
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$this->model->country
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$this->model->registeredCountry
);
$this->assertInstanceOf(
'GeoIP2\Record\RepresentedCountry',
'GeoIp2\Record\RepresentedCountry',
$this->model->representedCountry
);
$this->assertInstanceOf(
'GeoIP2\Record\Traits',
'GeoIp2\Record\Traits',
$this->model->traits
);
}

View File

@ -1,8 +1,8 @@
<?php
namespace GeoIP2\Test\Model;
namespace GeoIp2\Test\Model;
use GeoIP2\Model\Country;
use GeoIp2\Model\Country;
class NameTest extends \PHPUnit_Framework_TestCase
{
@ -46,7 +46,8 @@ class NameTest extends \PHPUnit_Framework_TestCase
);
}
public function testTwoFallbacks() {
public function testTwoFallbacks()
{
$model = new Country($this->raw, array('ru', 'ja'));
$this->assertEquals(

View File

@ -1,8 +1,8 @@
<?php
namespace GeoIP2\Test\Model;
namespace GeoIp2\Test\Model;
use GeoIP2\Model\Omni;
use GeoIp2\Model\Omni;
class OmniTest extends \PHPUnit_Framework_TestCase
{
@ -72,60 +72,60 @@ class OmniTest extends \PHPUnit_Framework_TestCase
$model = new Omni($raw, array('en'));
$this->assertInstanceOf(
'GeoIP2\Model\Omni',
'GeoIp2\Model\Omni',
$model,
'GeoIP2\Model\Omni object'
'GeoIp2\Model\Omni object'
);
$this->assertInstanceOf(
'GeoIP2\Record\City',
'GeoIp2\Record\City',
$model->city,
'$model->city'
);
$this->assertInstanceOf(
'GeoIP2\Record\Continent',
'GeoIp2\Record\Continent',
$model->continent,
'$model->continent'
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$model->country,
'$model->country'
);
$this->assertInstanceOf(
'GeoIP2\Record\Location',
'GeoIp2\Record\Location',
$model->location,
'$model->location'
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$model->registeredCountry,
'$model->registeredCountry'
);
$this->assertInstanceOf(
'GeoIP2\Record\RepresentedCountry',
'GeoIp2\Record\RepresentedCountry',
$model->representedCountry,
'$model->representedCountry'
);
$subdivisions = $model->subdivisions;
foreach ($subdivisions as $subdiv) {
$this->assertInstanceOf('GeoIP2\Record\Subdivision', $subdiv);
$this->assertInstanceOf('GeoIp2\Record\Subdivision', $subdiv);
}
$this->assertInstanceOf(
'GeoIP2\Record\Subdivision',
'GeoIp2\Record\Subdivision',
$model->mostSpecificSubdivision,
'$model->mostSpecificSubdivision'
);
$this->assertInstanceOf(
'GeoIP2\Record\Traits',
'GeoIp2\Record\Traits',
$model->traits,
'$model->traits'
);
@ -150,43 +150,43 @@ class OmniTest extends \PHPUnit_Framework_TestCase
$model = new Omni($raw, array('en'));
$this->assertInstanceOf(
'GeoIP2\Model\Omni',
'GeoIp2\Model\Omni',
$model,
'GeoIP2\Model\Omni object with no data except traits.ipAddress'
'GeoIp2\Model\Omni object with no data except traits.ipAddress'
);
$this->assertInstanceOf(
'GeoIP2\Record\City',
'GeoIp2\Record\City',
$model->city,
'$model->city'
);
$this->assertInstanceOf(
'GeoIP2\Record\Continent',
'GeoIp2\Record\Continent',
$model->continent,
'$model->continent'
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$model->country,
'$model->country'
);
$this->assertInstanceOf(
'GeoIP2\Record\Location',
'GeoIp2\Record\Location',
$model->location,
'$model->location'
);
$this->assertInstanceOf(
'GeoIP2\Record\Country',
'GeoIp2\Record\Country',
$model->registeredCountry,
'$model->registeredCountry'
);
$this->assertInstanceOf(
'GeoIP2\Record\RepresentedCountry',
'GeoIp2\Record\RepresentedCountry',
$model->representedCountry,
'$model->representedCountry'
);
@ -198,13 +198,13 @@ class OmniTest extends \PHPUnit_Framework_TestCase
);
$this->assertInstanceOf(
'GeoIP2\Record\Subdivision',
'GeoIp2\Record\Subdivision',
$model->mostSpecificSubdivision,
'$model->mostSpecificSubdivision'
);
$this->assertInstanceOf(
'GeoIP2\Record\Traits',
'GeoIp2\Record\Traits',
$model->traits,
'$model->traits'
);
@ -234,7 +234,7 @@ class OmniTest extends \PHPUnit_Framework_TestCase
$model = new Omni($raw, array('en'));
$this->assertInstanceOf(
'GeoIP2\Model\Omni',
'GeoIp2\Model\Omni',
$model,
'no exception when Omni model gets raw data with unknown keys'
);

View File

@ -1,8 +1,8 @@
<?php
namespace GeoIP2\Test\WebService;
namespace GeoIp2\Test\WebService;
use GeoIP2\WebService\Client;
use GeoIp2\WebService\Client;
use Guzzle\Http\Client as GuzzleClient;
use Guzzle\Http\Message\Response;
use Guzzle\Plugin\Mock\MockPlugin;
@ -91,7 +91,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$country = $this->client($this->getResponse('1.2.3.4'))
->country('1.2.3.4');
$this->assertInstanceOf('GeoIP2\Model\Country', $country);
$this->assertInstanceOf('GeoIp2\Model\Country', $country);
$this->assertEquals(
42,
@ -155,7 +155,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$omni = $this->client($this->getResponse('1.2.3.4'))
->omni('1.2.3.4');
$this->assertInstanceOf('GeoIP2\Model\Omni', $omni);
$this->assertInstanceOf('GeoIp2\Model\Omni', $omni);
$this->assertEquals(
42,
@ -169,7 +169,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$city = $this->client($this->getResponse('1.2.3.4'))
->city('1.2.3.4');
$this->assertInstanceOf('GeoIP2\Model\City', $city);
$this->assertInstanceOf('GeoIp2\Model\City', $city);
}
public function testMe()
@ -177,14 +177,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$client = $this->client($this->getResponse('me'));
$this->assertInstanceOf(
'GeoIP2\Model\CityIspOrg',
'GeoIp2\Model\CityIspOrg',
$client->cityIspOrg('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.
*/
public function testNoBodyException()
@ -195,7 +195,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:
*/
public function testBadBodyException()
@ -207,7 +207,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException GeoIP2\Exception\WebServiceException
* @expectedException GeoIp2\Exception\WebServiceException
* @expectedExceptionCode 400
* @expectedExceptionMessage The value "1.2.3" is not a valid ip address
*/
@ -220,7 +220,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 400
* @expectedExceptionMessage with no body
*/
@ -232,7 +232,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\GeoIP2Exception
* @expectedException GeoIp2\Exception\GeoIp2Exception
* @expectedExceptionMessage Response contains JSON but it does not specify code or error keys
*/
public function testWeirdErrorBodyIPException()
@ -244,7 +244,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 400
* @expectedExceptionMessage did not include the expected JSON body
*/
@ -257,7 +257,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 500
* @expectedExceptionMessage Received a server error (500)
*/
@ -270,7 +270,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 300
* @expectedExceptionMessage Received a very surprising HTTP status (300)
*/
@ -283,7 +283,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @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
*/

View File

@ -4,4 +4,4 @@ if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
die('Project dependencies missing');
}
$loader->add('GeoIP2\Test', __DIR__);
$loader->add('GeoIp2\Test', __DIR__);