Added most of the attributes for the City model
This commit is contained in:
parent
01bf8c2d7c
commit
45228dfad4
|
@ -5,15 +5,31 @@ namespace GeoIP2\Model;
|
||||||
class City extends Country
|
class City extends Country
|
||||||
{
|
{
|
||||||
//XXX use properties
|
//XXX use properties
|
||||||
public $city;
|
private $city;
|
||||||
public $location;
|
private $location;
|
||||||
public $postal;
|
private $postal;
|
||||||
public $subdivisions;
|
private $subdivisions = Array();
|
||||||
|
|
||||||
public function __construct($raw, $language)
|
public function __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'));
|
||||||
|
|
||||||
parent::__construct($raw, $language);
|
$this->createSubdivisions($raw, $languages);
|
||||||
|
|
||||||
|
parent::__construct($raw, $languages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createSubdivisions($raw, $languages) {
|
||||||
|
if(!isset($raw['subdivisions'])) return;
|
||||||
|
|
||||||
|
foreach ($raw['subdivisions'] as $sub) {
|
||||||
|
array_push($this->subdivisions,
|
||||||
|
new \GeoIP2\Record\Subdivision($sub, $languages));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,25 +4,36 @@ namespace GeoIP2\Model;
|
||||||
|
|
||||||
class Country
|
class Country
|
||||||
{
|
{
|
||||||
// XXX - use __get__
|
private $continent;
|
||||||
public $continent;
|
private $country;
|
||||||
public $country;
|
private $registeredCountry;
|
||||||
public $registeredCountry;
|
private $representedCountry;
|
||||||
public $representedCountry;
|
private $traits;
|
||||||
public $traits;
|
private $raw;
|
||||||
public $raw;
|
|
||||||
|
|
||||||
public function __construct($raw, $languages) {
|
public function __construct($raw, $languages) {
|
||||||
$this->raw = $raw;
|
$this->raw = $raw;
|
||||||
|
|
||||||
$this->continent = new \GeoIP2\Record\Continent($this->get('continent'), $languages);
|
$this->continent = new \GeoIP2\Record\Continent($this->get('continent'),
|
||||||
$this->country = new \GeoIP2\Record\Country($this->get('country'), $languages);
|
$languages);
|
||||||
$this->registeredCountry = new \GeoIP2\Record\Country($this->get('registered_country'), $languages);
|
$this->country = new \GeoIP2\Record\Country($this->get('country'),
|
||||||
$this->representedCountry = new \GeoIP2\Record\RepresentedCountry($this->get('represented_country'), $languages);
|
$languages);
|
||||||
|
$this->registeredCountry =
|
||||||
|
new \GeoIP2\Record\Country($this->get('registered_country'), $languages);
|
||||||
|
$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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get($field) {
|
protected function get($field) {
|
||||||
return isset($this->raw[$field]) ? $this->raw[$field] : Array();
|
return isset($this->raw[$field]) ? $this->raw[$field] : Array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __get ($var)
|
||||||
|
{
|
||||||
|
if ($var != "instance" && isset($this->$var)) return $this->$var;
|
||||||
|
|
||||||
|
throw new RuntimeException("Unknown attribute: $attr");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
8
src/GeoIP2/Record/Postal.php
Normal file
8
src/GeoIP2/Record/Postal.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GeoIP2\Record;
|
||||||
|
|
||||||
|
class Postal extends AbstractRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user