Add support for named records. Create all the objects for Country model

This commit is contained in:
Gregory Oschwald
2013-05-07 15:02:53 -07:00
parent 531e11f3e2
commit 01bf8c2d7c
3 changed files with 30 additions and 9 deletions
+13 -5
View File
@@ -7,14 +7,22 @@ class Country
// XXX - use __get__
public $continent;
public $country;
public $registered_country;
public $represented_country;
public $registeredCountry;
public $representedCountry;
public $traits;
public $raw;
public function __construct($raw, $language) {
$this->country = new \GeoIP2\Record\Country($raw['country']);
public function __construct($raw, $languages) {
$this->raw = $raw;
$this->continent = new \GeoIP2\Record\Continent($this->get('continent'), $languages);
$this->country = new \GeoIP2\Record\Country($this->get('country'), $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'));
}
private function get($field) {
return isset($this->raw[$field]) ? $this->raw[$field] : Array();
}
}