Started filling in Model and Record code
This commit is contained in:
parent
76a40bb2a1
commit
531e11f3e2
5
composer.json
Normal file
5
composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"guzzle/guzzle": "~3.1.1"
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Model;
|
||||
|
||||
class CityISPOrg
|
||||
class CityISPOrg extends City
|
||||
{
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
public function __construct($raw, $language) {
|
||||
$this->country = new \GeoIP2\Record\Country($raw['country']);
|
||||
|
||||
$this->raw = $raw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace GeoIP2\Model;
|
||||
|
||||
class Omni
|
||||
class Omni extends CityISPOrg
|
||||
{
|
||||
|
||||
}
|
||||
public function __construct($raw, $language) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
8
src/GeoIP2/Record/AbstractPlaceRecord.php
Normal file
8
src/GeoIP2/Record/AbstractPlaceRecord.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
abstract class AbstractPlaceRecord extends AbstractRecord
|
||||
{
|
||||
|
||||
}
|
18
src/GeoIP2/Record/AbstractRecord.php
Normal file
18
src/GeoIP2/Record/AbstractRecord.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
abstract class AbstractRecord
|
||||
{
|
||||
private $record;
|
||||
|
||||
public function __construct($record) {
|
||||
$this->record = $record;
|
||||
}
|
||||
|
||||
public function __get($attr) {
|
||||
if (isset($this->record[$attr])) return $this->record[$attr];
|
||||
|
||||
throw new RuntimeException("Unknown attribute: $attr");
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class City
|
||||
class City extends AbstractPlaceRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class Continent
|
||||
class Continent extends AbstractPlaceRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class Country
|
||||
class Country extends AbstractPlaceRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class Location
|
||||
class Location extends AbstractRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class RepresentedCountry
|
||||
class RepresentedCountry extends Country
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class Subdivision
|
||||
class Subdivision extends AbstractPlaceRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GeoIP2\Record;
|
||||
|
||||
class Traits
|
||||
class Traits extends AbstractRecord
|
||||
{
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user