Added most of the attributes for the City model

This commit is contained in:
Gregory Oschwald
2013-05-07 15:36:20 -07:00
parent 01bf8c2d7c
commit 45228dfad4
3 changed files with 53 additions and 18 deletions
+22 -6
View File
@@ -5,15 +5,31 @@ namespace GeoIP2\Model;
class City extends Country
{
//XXX use properties
public $city;
public $location;
public $postal;
public $subdivisions;
private $city;
private $location;
private $postal;
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));
}
}
}