diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ebd575d --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "guzzle/guzzle": "~3.1.1" + } +} diff --git a/src/GeoIP2/Model/City.php b/src/GeoIP2/Model/City.php index e1add28..3a480d6 100644 --- a/src/GeoIP2/Model/City.php +++ b/src/GeoIP2/Model/City.php @@ -2,11 +2,18 @@ namespace GeoIP2\Model; -class City +class City extends Country { + //XXX use properties + public $city; + public $location; + public $postal; + public $subdivisions; public function __construct($raw, $language) { + + parent::__construct($raw, $language); } } \ No newline at end of file diff --git a/src/GeoIP2/Model/CityISPOrg.php b/src/GeoIP2/Model/CityISPOrg.php index f4a1853..4be358d 100644 --- a/src/GeoIP2/Model/CityISPOrg.php +++ b/src/GeoIP2/Model/CityISPOrg.php @@ -2,7 +2,7 @@ namespace GeoIP2\Model; -class CityISPOrg +class CityISPOrg extends City { } \ No newline at end of file diff --git a/src/GeoIP2/Model/Country.php b/src/GeoIP2/Model/Country.php index 005407e..1f9f38a 100644 --- a/src/GeoIP2/Model/Country.php +++ b/src/GeoIP2/Model/Country.php @@ -4,5 +4,17 @@ namespace GeoIP2\Model; class Country { + // XXX - use __get__ + public $continent; + public $country; + public $registered_country; + public $represented_country; + public $traits; + public $raw; -} \ No newline at end of file + public function __construct($raw, $language) { + $this->country = new \GeoIP2\Record\Country($raw['country']); + + $this->raw = $raw; + } +} diff --git a/src/GeoIP2/Model/Omni.php b/src/GeoIP2/Model/Omni.php index db80dc1..b48062b 100644 --- a/src/GeoIP2/Model/Omni.php +++ b/src/GeoIP2/Model/Omni.php @@ -2,7 +2,10 @@ namespace GeoIP2\Model; -class Omni +class Omni extends CityISPOrg { -} \ No newline at end of file + public function __construct($raw, $language) { + + } +} diff --git a/src/GeoIP2/Record/AbstractPlaceRecord.php b/src/GeoIP2/Record/AbstractPlaceRecord.php new file mode 100644 index 0000000..2726c62 --- /dev/null +++ b/src/GeoIP2/Record/AbstractPlaceRecord.php @@ -0,0 +1,8 @@ +record = $record; + } + + public function __get($attr) { + if (isset($this->record[$attr])) return $this->record[$attr]; + + throw new RuntimeException("Unknown attribute: $attr"); + } +} \ No newline at end of file diff --git a/src/GeoIP2/Record/City.php b/src/GeoIP2/Record/City.php index 8a9a194..9a1454e 100644 --- a/src/GeoIP2/Record/City.php +++ b/src/GeoIP2/Record/City.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class City +class City extends AbstractPlaceRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Record/Continent.php b/src/GeoIP2/Record/Continent.php index 046151f..efb0373 100644 --- a/src/GeoIP2/Record/Continent.php +++ b/src/GeoIP2/Record/Continent.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class Continent +class Continent extends AbstractPlaceRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Record/Country.php b/src/GeoIP2/Record/Country.php index da5fe12..0bc1f29 100644 --- a/src/GeoIP2/Record/Country.php +++ b/src/GeoIP2/Record/Country.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class Country +class Country extends AbstractPlaceRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Record/Location.php b/src/GeoIP2/Record/Location.php index 00f0e75..dde5aeb 100644 --- a/src/GeoIP2/Record/Location.php +++ b/src/GeoIP2/Record/Location.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class Location +class Location extends AbstractRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Record/RepresentedCountry.php b/src/GeoIP2/Record/RepresentedCountry.php index 7f05349..b8c83f1 100644 --- a/src/GeoIP2/Record/RepresentedCountry.php +++ b/src/GeoIP2/Record/RepresentedCountry.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class RepresentedCountry +class RepresentedCountry extends Country { } \ No newline at end of file diff --git a/src/GeoIP2/Record/Subdivision.php b/src/GeoIP2/Record/Subdivision.php index d370a6c..0da51f1 100644 --- a/src/GeoIP2/Record/Subdivision.php +++ b/src/GeoIP2/Record/Subdivision.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class Subdivision +class Subdivision extends AbstractPlaceRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Record/Traits.php b/src/GeoIP2/Record/Traits.php index 1b28b3f..a7bcdc0 100644 --- a/src/GeoIP2/Record/Traits.php +++ b/src/GeoIP2/Record/Traits.php @@ -2,7 +2,7 @@ namespace GeoIP2\Record; -class Traits +class Traits extends AbstractRecord { } \ No newline at end of file diff --git a/src/GeoIP2/Webservice/Client.php b/src/GeoIP2/Webservice/Client.php index f1755ca..b44b745 100644 --- a/src/GeoIP2/Webservice/Client.php +++ b/src/GeoIP2/Webservice/Client.php @@ -19,7 +19,7 @@ class Client private $language; private $base_uri = 'https://geoip.maxmind.com/geoip/v2.0'; - function __construct($user_id, $license_key, $language='en') + public function __construct($user_id, $license_key, $language='en') { $this->user_id = $user_id; $this->license_key = $license_key; @@ -134,4 +134,4 @@ class Client "($status) for $uri", $status, $uri); } -} \ No newline at end of file +}