44 Commits

Author SHA1 Message Date
Gregory Oschwald
c898f76a50 Release of 0.3.0 with updated namespace 2013-07-12 07:01:27 -07:00
Gregory Oschwald
8a265a763e Remove HipChat notifications due to popular demand. 2013-07-12 07:00:48 -07:00
Gregory Oschwald
3579ce7297 Doc updates plus HipChat notification 2013-07-10 19:25:09 -07:00
Gregory Oschwald
aa88c3040f Fixed a couple of incorrect case changes 2013-07-10 15:35:09 -07:00
Gregory Oschwald
5df4bbee47 Fix composer file 2013-07-10 15:30:33 -07:00
Gregory Oschwald
e60181f13a Rename GeoIP2 => GeoIp2 for consistency 2013-07-10 15:24:40 -07:00
Gregory Oschwald
1c37dcac03 Updated change log 2013-06-10 09:44:28 -07:00
Gregory Oschwald
f4898f7f90 Added beta note with a link to our website and GetSatisfaction 2013-06-06 09:28:51 -07:00
Olaf Alders
6f85654820 s/associated the IP/associated with the IP/ 2013-05-29 16:36:25 -04:00
Olaf Alders
fc74279d11 s/block in/block/ 2013-05-29 15:55:55 -04:00
Olaf Alders
b8aa4bc429 Update versioning copy 2013-05-29 15:52:47 -04:00
Gregory Oschwald
d9a87dd5bd Updated version in Composer example 2013-05-29 07:43:44 -07:00
Gregory Oschwald
b45b3c1ed5 Updated alpha note 2013-05-29 07:41:24 -07:00
Gregory Oschwald
3431141943 Updated for 0.2.0 2013-05-29 07:40:18 -07:00
Gregory Oschwald
c90fe87d3d CWD fix 2013-05-24 19:37:10 -07:00
Gregory Oschwald
1c256e1e64 Updated release script for new templates 2013-05-24 19:35:47 -07:00
Gregory Oschwald
1d294bd473 Hopefully a fix for uncommited files 2013-05-24 14:30:51 -07:00
Gregory Oschwald
9a9a1e86b2 Added missing styling 2013-05-24 14:25:57 -07:00
Gregory Oschwald
893c715047 Updated markdown. Remove author. 2013-05-24 14:16:43 -07:00
Gregory Oschwald
f99ac351ab Updated apigen flags 2013-05-24 13:38:58 -07:00
Gregory Oschwald
4d9957ccf5 Create a version file 2013-05-24 13:27:37 -07:00
Gregory Oschwald
3a382f0d26 Updated release script 2013-05-24 13:12:45 -07:00
Gregory Oschwald
c4867ef7c7 Updated release script 2013-05-24 12:58:17 -07:00
Gregory Oschwald
bfb8de7ffa Fixed typo 2013-05-24 12:05:52 -07:00
Gregory Oschwald
e38c46950f Added a basic release script 2013-05-24 12:04:06 -07:00
Gregory Oschwald
7f81643a98 Updated .gitignore 2013-05-24 11:21:48 -07:00
Gregory Oschwald
750c23fb5c Fixed space issue 2013-05-21 13:56:00 -07:00
Gregory Oschwald
e0baddaec0 Added queriesRemaining 2013-05-21 13:46:11 -07:00
Gregory Oschwald
89f1bbdb65 Switched continent_code to code 2013-05-21 13:28:37 -07:00
Gregory Oschwald
559e62a30c Added alpha notice 2013-05-21 12:34:10 -07:00
Gregory Oschwald
b179e29ee7 Rename GenericException to GeoIP2Exception 2013-05-20 15:42:52 -07:00
Gregory Oschwald
73d6f15823 Get rid of references to "Precision" 2013-05-20 15:38:21 -07:00
Gregory Oschwald
2c23be78fe Try --prefer-source to see if reduces Travis errors 2013-05-20 14:13:45 -07:00
Gregory Oschwald
5eda52e1db Add test for city call 2013-05-20 13:47:17 -07:00
Gregory Oschwald
b383cf82b3 Run composer in no interaction mode 2013-05-20 13:38:12 -07:00
Gregory Oschwald
0f76a28527 Update composer if it is old. 2013-05-20 13:31:06 -07:00
Gregory Oschwald
2b1ec4abbe Install with --dev for Coveralls 2013-05-20 13:25:25 -07:00
Gregory Oschwald
ef618d06c1 Fixed broken unit test 2013-05-20 13:18:05 -07:00
Gregory Oschwald
aeba497703 Added a very basic omni test as we didn't cover it previously 2013-05-20 13:15:25 -07:00
Gregory Oschwald
57f6af0bfd Using local composer didn't work 2013-05-20 13:10:46 -07:00
Gregory Oschwald
fd1231e5f8 Updates for Coveralls. Also always installing a local composer as the Travis one is giving us issues 2013-05-20 12:50:10 -07:00
Gregory Oschwald
b077a3cda7 Try Coveralls 2013-05-20 12:42:18 -07:00
Gregory Oschwald
04629e039b Added missing isSatelliteProvider 2013-05-20 11:37:32 -07:00
Gregory Oschwald
f44db25129 Fixed typo 2013-05-20 11:03:38 -07:00
32 changed files with 410 additions and 228 deletions

4
.gitignore vendored
View File

@@ -1,7 +1,9 @@
bin/
_site
.gh-pages
composer.lock
composer.phar
phpunit.xml
geoip2-php.sublime-*
vendor/
*.sw?
t.php

View File

@@ -7,13 +7,17 @@ php:
before_install:
- composer self-update
- composer install
- composer install --dev -n --prefer-source
- pyrus install pear/PHP_CodeSniffer
- phpenv rehash
script:
- mkdir -p build/logs
- phpcs --standard=PSR2 src/
- phpunit
- phpunit -c phpunit.xml.dist
after_script:
- php vendor/bin/coveralls
notifications:
email:

View File

@@ -1,14 +1,36 @@
CHANGELOG
=========
0.3.0 (2013-07-12)
------------------
* In namespaces and class names, "GeoIP2" was renamed to "GeoIp2" to improve
consistency.
0.2.1 (2013-06-10)
------------------
* First official beta release.
* Documentation updates and corrections.
0.2.0 (2013-05-29)
------------------
* `GenericException` was renamed to `GeoIP2Exception`.
* We now support more languages. The new languages are de, es, fr, and pt-BR.
* The REST API now returns a record with data about your account. There is
a new `GeoIP\Records\MaxMind` class for this data.
* The `continentCode` attribute on `Continent` was renamed to `code`.
* Documentation updates.
0.1.1 (2013-05-14)
------------------
* Updated Guzzle version requirement
* Fixed Composer example in README.md
* Updated Guzzle version requirement.
* Fixed Composer example in README.md.
0.1.0 (2013-05-13)
------------------
* Initial release
* Initial release.

View File

@@ -1,15 +1,26 @@
# GeoIP2 PHP API #
## Beta Note ##
This is a beta release. The API may change before the first production
release, which will be numbered 2.0.0.
You may find information on the GeoIP2 beta release process on [our
website](http://www.maxmind.com/en/geoip2_beta).
To provide feedback or get support during the beta, please see the
[MaxMind Customer Community](https://getsatisfaction.com/maxmind).
## Description ##
Currently, this distribution provides an API for the GeoIP2 web services
(as documented at http://dev.maxmind.com/geoip/geoip2/web-services).
Currently, this distribution provides an API for the [GeoIP2 web services]
(http://dev.maxmind.com/geoip/geoip2/web-services).
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 ##
@@ -22,7 +33,7 @@ To do this, add ```geoip2/geoip2``` to your ```composer.json``` file.
```json
{
"require": {
"geoip2/geoip2": "0.1.*"
"geoip2/geoip2": "0.3.*"
}
}
```
@@ -52,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.
@@ -68,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');
@@ -78,22 +89,22 @@ echo $omni->country->isoCode;
## Exceptions ##
For details on the possible errors returned by the web service itself, see
http://dev.maxmind.com/geoip2/geoip/web-services for the GeoIP2 web service
docs.
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\GenericException```.
throws a ```\GeoIp2\Exception\GeoIp2Exception```.
## What data is returned? ##
@@ -105,11 +116,12 @@ piece of data for any given IP address.
Because of these factors, it is possible for any end point to return a record
where some or all of the attributes are unpopulated.
See http://dev.maxmind.com/geoip/geoip2/web-services for details on what data
each end point may return.
See the
[GeoIP2 web service docs](http://dev.maxmind.com/geoip/geoip2/web-services)
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.
@@ -132,11 +144,11 @@ the GeoNames premium data set.
## Reporting data problems ##
If the problem you find is that an IP address is incorrectly mapped,
please submit your correction to MaxMind at
http://www.maxmind.com/en/correction.
please
[submit your correction to MaxMind](http://www.maxmind.com/en/correction).
If you find some other sort of mistake, like an incorrect spelling,
please check the GeoNames site (http://www.geonames.org/) first. Once
please check the [GeoNames site](http://www.geonames.org/) first. Once
you've searched for a place and found it on the GeoNames map view, there
are a number of links you can use to correct data ("move", "edit",
"alternate names", etc.). Once the correction is part of the GeoNames
@@ -144,17 +156,17 @@ data set, it will be automatically incorporated into future MaxMind
releases.
If you are a paying MaxMind customer and you're not sure where to submit
a correction, please contact MaxMind support at
http://www.maxmind.com/en/support for help.
a correction, please
[contact MaxMind support](http://www.maxmind.com/en/support) for help.
## Other Support ##
Please report all issues with this code using the GitHub issue tracker
at https://github.com/maxmind/GeoIP2-php/issues
Please report all issues with this code using the
[GitHub issue tracker](https://github.com/maxmind/GeoIP2-php/issues).
If you are having an issue with a MaxMind service that is not specific
to the client API please see http://www.maxmind.com/en/support for
details.
to the client API, please see
[our support page](http://www.maxmind.com/en/support).
## Requirements ##
@@ -172,10 +184,6 @@ PSR-2 style guidelines. Please include unit tests whenever possible.
The GeoIP2 PHP API uses [Semantic Versioning](http://semver.org/).
## Author ##
[Gregory Oschwald](mailto:goschwald@maxmind.com)
## Copyright and License ##
This software is Copyright (c) 2013 by MaxMind, Inc.

63
bin/release.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
TAG=$1
if [ -z $TAG ]; then
echo "Please specify a tag"
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo ". is not clean." >&2
exit 1
fi
if [ ! -d .gh-pages ]; then
echo "Checking out gh-pages in .gh-pages"
git clone -b gh-pages git@git.maxmind.com:GeoIP2-php .gh-pages
cd .gh-pages
else
echo "Updating .gh-pages"
cd .gh-pages
git pull
fi
if [ -n "$(git status --porcelain)" ]; then
echo ".gh-pages is not clean" >&2
exit 1
fi
apigen --quiet --download --title "GeoIP2 PHP API $TAG" --source ../src --destination doc/$TAG
PAGE=index.md
cat <<EOF > $PAGE
---
layout: default
title: MaxMind GeoIP2 PHP API
language: php
version: $TAG
---
EOF
cat ../README.md >> $PAGE
git add doc/
git commit -m "Updated for $TAG" -a
read -e -p "Push to origin? " SHOULD_PUSH
if [ "$SHOULD_PUSH" != "y" ]; then
echo "Aborting"
exit 1
fi
# If we don't push directly to github, the page doesn't get built for some
# reason.
git push git@github.com:maxmind/GeoIP2-php.git
git push
cd ..
git tag $TAG
git push
git push --tags

View File

@@ -17,9 +17,10 @@
"php": ">=5.3.1"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
"phpunit/phpunit": "3.7.*",
"satooshi/php-coveralls": "dev-master"
},
"autoload": {
"psr-0": { "GeoIP2": "src/" }
"psr-0": { "GeoIp2": "src/" }
}
}

View File

@@ -3,13 +3,18 @@
<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>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>

View File

@@ -1,10 +0,0 @@
<?php
namespace GeoIP2\Exception;
/**
* This class represents a generic error.
*/
class GenericException 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 GenericException
class HttpException extends GeoIp2Exception
{
/**
* The URI queried

View File

@@ -1,9 +1,9 @@
<?php
namespace GeoIP2\Exception;
namespace GeoIp2\Exception;
/**
* This class represents an error returned by MaxMind's GeoIP2 Precision
* This class represents an error returned by MaxMind's GeoIP2
* web service.
*/
class WebServiceException extends HttpException

View File

@@ -1,39 +1,42 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2 Precision
* This class provides a model for the data returned by the GeoIP2
* City 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 Country 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\Country $registeredCountry Registered country
* @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 in and may differ from the
* 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
@@ -41,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
@@ -75,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);
}
@@ -91,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)
);
}
}
@@ -111,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,39 +1,42 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2 Precision
* 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 Country 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\Country $registeredCountry Registered country
* @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 in and may differ from the
* 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
@@ -41,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,24 +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\Country $registeredCountry Registered country
* @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 in and may differ from the
* 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
@@ -35,6 +38,7 @@ class Country
private $continent;
private $country;
private $languages;
private $maxmind;
private $registeredCountry;
private $representedCountry;
private $traits;
@@ -47,23 +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->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,39 +1,42 @@
<?php
namespace GeoIP2\Model;
namespace GeoIp2\Model;
/**
* This class provides a model for the data returned by the GeoIP2 Precision
* This class provides a model for the data returned by the GeoIP2
* Omni 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 Country 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\Country $registeredCountry Registered country
* @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 in and may differ from the
* 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
@@ -41,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,15 +1,14 @@
<?php
namespace GeoIP2\Record;
namespace GeoIp2\Record;
/**
* Contains data for the continent record associated with an IP address
*
* This record is returned by all the end points.
*
* @property string $continentCode A two character continent code
* like "NA" (North America) or "OC" (Oceania). This attribute is returned
* by all end points.
* @property string $code A two character continent code like "NA" (North
* America) or "OC" (Oceania). This attribute is returned by all end points.
*
* @property int $geonameId The GeoName ID for the continent. This attribute
* is returned by all end points.
@@ -27,7 +26,7 @@ class Continent extends AbstractPlaceRecord
* @ignore
*/
protected $validAttributes = array(
'continentCode',
'code',
'geonameId',
'names'
);

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

@@ -0,0 +1,19 @@
<?php
namespace GeoIp2\Record;
/**
* Contains data about your account.
*
* This record is returned by all the end points.
*
* @property int $queriesRemaining The number of remaining queries you have
* for the end point you are calling.
*/
class MaxMind extends AbstractRecord
{
/**
* @ignore
*/
protected $validAttributes = array('queriesRemaining');
}

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;
/**
*
@@ -35,12 +35,16 @@ namespace GeoIP2\Record;
* anonymous proxy. See {@link http://dev.maxmind.com/faq/geoip#anonproxy}
* for further details. This attribute is returned by all end points.
*
* @property string $isp The name of the ISP associated the IP address.
* @property boolean $isSatelliteProvider This is true if the IP belongs
* to a satellite Internet provider. This attribute is returned by all
* end points.
*
* @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
* points.
*
* @property string $organization The name of the organization associated
* 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/ISP/Org
* and Omni end points.
*
* @property string $userType <p>The user type associated with the IP

View File

@@ -1,21 +1,21 @@
<?php
namespace GeoIP2\WebService;
namespace GeoIp2\WebService;
use GeoIP2\Exception\GenericException;
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 GeoIP Precision 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\GenericException}.
* client throws a {@link \GeoIp2\Exception\GeoIp2Exception}.
*/
class Client
{
@@ -100,19 +100,19 @@ class Client
}
/**
* This method calls the GeoIP2 Precision City endpoint.
* This method calls the GeoIP2 City 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\City
* @return \GeoIp2\Model\City
*
* @throws \GeoIP2\Exception\GenericException 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
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
*/
public function city($ipAddress = 'me')
@@ -127,13 +127,13 @@ 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\GenericException 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
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
*/
public function country($ipAddress = 'me')
@@ -142,19 +142,19 @@ class Client
}
/**
* This method calls the GeoIP2 Precision City/ISP/Org endpoint.
* This method calls the GeoIP2 City/ISP/Org 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\CityIspOrg
* @return \GeoIp2\Model\CityIspOrg
*
* @throws \GeoIP2\Exception\GenericException 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
* @throws \GeoIp2\Exception\WebServiceException if an error was returned
* by MaxMind's GeoIP2 web service.
*/
public function cityIspOrg($ipAddress = 'me')
@@ -163,19 +163,19 @@ class Client
}
/**
* This method calls the GeoIP2 Precision Omni endpoint.
* 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
* @return \GeoIp2\Model\Omni
*
* @throws \GeoIP2\Exception\GenericException 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
* @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 GenericException(
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 GenericException(
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 GenericException(
throw new GeoIp2Exception(
'Response contains JSON but it does not specify ' .
'code or error keys: ' . $response->getBody()
);

View File

@@ -1,15 +1,15 @@
<?php
namespace GeoIP2\Test\Model;
namespace GeoIp2\Test\Model;
use GeoIP2\Model\Country;
use GeoIp2\Model\Country;
class CountryTest extends \PHPUnit_Framework_TestCase
{
private $raw = array(
'continent' => array(
'continent_code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
),
@@ -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
);
}
@@ -75,8 +75,8 @@ class CountryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
'NA',
$this->model->continent->continentCode,
'continent continent_code is NA'
$this->model->continent->code,
'continent code is NA'
);
$this->assertEquals(

View File

@@ -1,14 +1,14 @@
<?php
namespace GeoIP2\Test\Model;
namespace GeoIp2\Test\Model;
use GeoIP2\Model\Country;
use GeoIp2\Model\Country;
class NameTest extends \PHPUnit_Framework_TestCase
{
public $raw = array(
'continent' => array(
'continent_code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array(
'en' => 'North America',
@@ -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
{
@@ -17,7 +17,7 @@ class OmniTest extends \PHPUnit_Framework_TestCase
'names' => array( 'en' => 'Minneapolis' ),
),
'continent' => array(
'continent_code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
),
@@ -36,6 +36,9 @@ class OmniTest extends \PHPUnit_Framework_TestCase
'postal_confidence' => 33,
'time_zone' => 'America/Chicago',
),
'maxmind' => array(
'queries_remaining' => 22,
),
'registered_country' => array(
'geoname_id' => 2,
'iso_code' => 'CA',
@@ -69,64 +72,70 @@ 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'
);
$this->assertEquals(
22,
$model->maxmind->queriesRemaining,
'queriesRemaining is correct'
);
$this->assertEquals(
$raw,
$model->raw,
@@ -141,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'
);
@@ -189,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'
);
@@ -225,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;
@@ -13,7 +13,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
private $country
= array(
'continent' => array(
'continent_code' => 'NA',
'code' => 'NA',
'geoname_id' => 42,
'names' => array( 'en' => 'North America' ),
),
@@ -22,6 +22,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
'iso_code' => 'US',
'names' => array( 'en' => 'United States of America' ),
),
'maxmind' => array('queries_remaining' => 11),
'traits' => array(
'ip_address' => '1.2.3.4',
),
@@ -90,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,
@@ -100,8 +101,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
'NA',
$country->continent->continentCode,
'continent continent_code is NA'
$country->continent->code,
'continent code is NA'
);
$this->assertEquals(
@@ -139,6 +140,36 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$country->country->name,
'country name is United States of America'
);
$this->assertEquals(
11,
$country->maxmind->queriesRemaining,
'queriesRemaining is correct'
);
}
public function testOmni()
{
$omni = $this->client($this->getResponse('1.2.3.4'))
->omni('1.2.3.4');
$this->assertInstanceOf('GeoIp2\Model\Omni', $omni);
$this->assertEquals(
42,
$omni->continent->geonameId,
'continent geoname_id is 42'
);
}
public function testCity()
{
$city = $this->client($this->getResponse('1.2.3.4'))
->city('1.2.3.4');
$this->assertInstanceOf('GeoIp2\Model\City', $city);
}
public function testMe()
@@ -146,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\GenericException
* @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()
@@ -164,7 +195,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\GenericException
* @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()
@@ -176,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
*/
@@ -189,7 +220,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\HttpException
* @expectedException GeoIp2\Exception\HttpException
* @expectedExceptionCode 400
* @expectedExceptionMessage with no body
*/
@@ -201,7 +232,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException GeoIP2\Exception\GenericException
* @expectedException GeoIp2\Exception\GeoIp2Exception
* @expectedExceptionMessage Response contains JSON but it does not specify code or error keys
*/
public function testWeirdErrorBodyIPException()
@@ -213,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
*/
@@ -226,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)
*/
@@ -239,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)
*/
@@ -252,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__);