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
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace GeoIp2\Record;
abstract class AbstractPlaceRecord extends AbstractRecord
{
private $languages;
/**
* @ignore
*/
public function __construct($record, $languages)
{
$this->languages = $languages;
parent::__construct($record);
}
/**
* @ignore
*/
public function __get($attr)
{
if ($attr == 'name') {
return $this->name();
} else {
return parent::__get($attr);
}
}
private function name()
{
foreach ($this->languages as $language) {
if (isset($this->names[$language])) {
return $this->names[$language];
}
}
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace GeoIp2\Record;
abstract class AbstractRecord
{
private $record;
/**
* @ignore
*/
public function __construct($record)
{
$this->record = $record;
}
/**
* @ignore
*/
public function __get($attr)
{
$valid = in_array($attr, $this->validAttributes);
// XXX - kind of ugly but greatly reduces boilerplate code
$key = strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
if ($valid && isset($this->record[$key])) {
return $this->record[$key];
} elseif ($valid) {
return null;
} else {
throw new \RuntimeException("Unknown attribute: $attr");
}
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace GeoIp2\Record;
/**
* City-level data associated with an IP address.
*
* This record is returned by all the end points except the Country end point.
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the city is correct. This attribute is only available
* from the Omni end point.
*
* @property int $geonameId The GeoName ID for the city. This attribute
* is returned by all end points.
*
* @property string $name The name of the city based on the languages list
* passed to the constructor. This attribute is returned by all end points.
*
* @property array $names A array map where the keys are language codes
* and the values are names. This attribute is returned by all end points.
*/
class City extends AbstractPlaceRecord
{
/**
* @ignore
*/
protected $validAttributes = array('confidence', 'geonameId', 'names');
}
+33
View File
@@ -0,0 +1,33 @@
<?php
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 $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.
*
* @property string $name Returns the name of the continent based on the
* languages list passed to the constructor. This attribute is returned by
* all end points.
*
* @property array $names An array map where the keys are language codes
* and the values are names. This attribute is returned by all end points.
*/
class Continent extends AbstractPlaceRecord
{
/**
* @ignore
*/
protected $validAttributes = array(
'code',
'geonameId',
'names'
);
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace GeoIp2\Record;
/**
* Contains data for the country record associated with an IP address
*
* This record is returned by all the end points.
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the country is correct. This attribute is only available
* from the Omni end point.
*
* @property int $geonameId The GeoName ID for the country. This attribute is
* returned by all end points.
*
* @property string $isoCode The {@link http://en.wikipedia.org/wiki/ISO_3166-1
* two-character ISO 3166-1 alpha code} for the country. This attribute is
* returned by all end points.
*
* @property string $name The name of the country based on the languages list
* passed to the constructor. This attribute is returned by all end points.
*
* @property array $names An array map where the keys are language codes and
* the values are names. This attribute is returned by all end points.
*/
class Country extends AbstractPlaceRecord
{
/**
* @ignore
*/
protected $validAttributes = array(
'confidence',
'geonameId',
'isoCode',
'names'
);
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace GeoIp2\Record;
/**
* Contains data for the location record associated with an IP address
*
* This record is returned by all the end points except the Country end point.
*
* @property int $accuracyRadius The radius in kilometers around the
* specified location where the IP address is likely to be. This attribute
* is only available from the Omni end point.
*
* @property float $latitude The latitude of the location as a floating
* point number. This attribute is returned by all end points except the
* Country end point.
*
* @property float $longitude The longitude of the location as a
* floating point number. This attribute is returned by all end points
* except the Country end point.
*
* @property int $metroCode The metro code of the location if the location
* is in the US. MaxMind returns the same metro codes as the
* {@link
* https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions
* Google AdWords API}. This attribute is returned by all end points except
* the Country end point.
*
* @property string $timeZone The time zone associated with location, as
* specified by the {@link http://www.iana.org/time-zones IANA Time Zone
* Database}, e.g., "America/New_York". This attribute is returned by all
* end points except the Country end point.
*/
class Location extends AbstractRecord
{
/**
* @ignore
*/
protected $validAttributes = array(
'accuracyRadius',
'latitude',
'longitude',
'metroCode',
'postalCode',
'postalConfidence',
'timeZone'
);
}
+19
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');
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace GeoIp2\Record;
/**
* Contains data for the postal record associated with an IP address
*
* This record is returned by all the end points except the Country end point.
*
* @property string $code The postal code of the location. Postal codes are
* not available for all countries. In some countries, this will only contain
* part of the postal code. This attribute is returned by all end points
* except the Country end point.
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the postal code is correct. This attribute is only
* available from the Omni end point.
*/
class Postal extends AbstractRecord
{
/**
* @ignore
*/
protected $validAttributes = array('code', 'confidence');
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace GeoIp2\Record;
/**
* Contains data for the represented country associated with an IP address
*
* This class contains the country-level data associated with an IP address
* for the IP's represented country. The represented country is the country
* represented by something like a military base or embassy.
*
* This record is returned by all the end points.
*
* @property int $confidence A value from 0-100 indicating MaxMind's
* confidence that the country is correct. This attribute is only available
* from the Omni end point.
*
* @property int $geonameId The GeoName ID for the country. This attribute is
* returned by all end points.
*
* @property string $isoCode The {@link http://en.wikipedia.org/wiki/ISO_3166-1
* two-character ISO 3166-1 alpha code} for the country. This attribute is
* returned by all end points.
*
* @property string $name The name of the country based on the languages list
* passed to the constructor. This attribute is returned by all end points.
*
* @property array $names An array map where the keys are language codes and
* the values are names. This attribute is returned by all end points.
*
* @property string $type A string indicating the type of entity that is
* representing the country. Currently we only return <code>military</code>
* but this could expand to include other types such as <code>embassy</code>
* in the future. Returned by all endpoints.
*/
class RepresentedCountry extends Country
{
protected $validAttributes = array(
'confidence',
'geonameId',
'isoCode',
'namespace',
'type'
);
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace GeoIp2\Record;
/**
*
* Contains data for the subdivisions associated with an IP address
*
* This record is returned by all the end points except the Country end point.
*
* @property int $confidence This is a value from 0-100 indicating MaxMind's
* confidence that the subdivision is correct. This attribute is only
* available from the Omni end point.
*
* @property int $geonameId This is a GeoName ID for the subdivision. This
* attribute is returned by all end points except Country.
*
* @property string $isoCode This is a string up to three characters long
* contain the subdivision portion of the {@link
* http://en.wikipedia.org/wiki/ISO_3166-2 ISO 3166-2 code}. This attribute
* is returned by all end points except Country.
*
* @property string $name The name of the subdivision based on the languages
* list passed to the constructor. This attribute is returned by all end
* points except Country.
*
* @property array $names An array map where the keys are language codes and
* the values are names. This attribute is returned by all end points except
* Country.
*/
class Subdivision extends AbstractPlaceRecord
{
/**
* @ignore
*/
protected $validAttributes = array(
'confidence',
'geonameId',
'isoCode',
'names'
);
}
+87
View File
@@ -0,0 +1,87 @@
<?php
namespace GeoIp2\Record;
/**
*
* Contains data for the traits record associated with an IP address
*
* This record is returned by all the end points.
*
* @property int $autonomousSystemNumber The {@link
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
* system number} associated with the IP address. This attribute is only
* available from the City/ISP/Org and Omni end points.
*
* @property string $autonomousSystemOrganization The organization
* associated with the registered {@link
* http://en.wikipedia.org/wiki/Autonomous_system_(Internet) autonomous
* system number} for the IP address. This attribute is only available from
* the City/ISP/Org and Omni end points.
*
* @property string $domain The second level domain associated with the
* IP address. This will be something like "example.com" or "example.co.uk",
* not "foo.example.com". This attribute is only available from the
* City/ISP/Org and Omni end points.
*
* @property string $ipAddress The IP address that the data in the model
* is for. If you performed a "me" lookup against the web service, this
* will be the externally routable IP address for the system the code is
* running on. If the system is behind a NAT, this may differ from the IP
* address locally assigned to it. This attribute is returned by all end
* points.
*
* @property boolean $isAnonymousProxy This is true if the IP is an
* anonymous proxy. See {@link http://dev.maxmind.com/faq/geoip#anonproxy}
* for further details. This attribute is returned by all end points.
*
* @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
* 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
* address. This can be one of the following values:</p>
* <ul>
* <li>business
* <li>cafe
* <li>cellular
* <li>college
* <li>content_delivery_network
* <li>dialup
* <li>government
* <li>hosting
* <li>library
* <li>military
* <li>residential
* <li>router
* <li>school
* <li>search_engine_spider
* <li>traveler
* </ul>
* <p>This attribute is only available from the Omni end point.</p>
*/
class Traits extends AbstractRecord
{
/**
* @ignore
*/
protected $validAttributes = array(
'autonomousSystemNumber',
'autonomousSystemOrganization',
'domain',
'isAnonymousProxy',
'isSatelliteProvider',
'isp',
'ipAddress',
'organization',
'userType'
);
}