1 <?php
2
3 namespace GeoIp2\Model;
4
5 /**
6 * Model class for the data returned by GeoIP2 Country web service and database.
7 *
8 * The only difference between the City and Insights model classes is which
9 * fields in each record may be populated. See
10 * http://dev.maxmind.com/geoip/geoip2/web-services more details.
11 *
12 * @property-read \GeoIp2\Record\Continent $continent Continent data for the
13 * requested IP address.
14 *
15 * @property-read \GeoIp2\Record\Country $country Country data for the requested
16 * IP address. This object represents the country where MaxMind believes the
17 * end user is located.
18 *
19 * @property-read \GeoIp2\Record\MaxMind $maxmind Data related to your MaxMind
20 * account.
21 *
22 * @property-read \GeoIp2\Record\Country $registeredCountry Registered country
23 * data for the requested IP address. This record represents the country
24 * where the ISP has registered a given IP block and may differ from the
25 * user's country.
26 *
27 * @property-read \GeoIp2\Record\RepresentedCountry $representedCountry
28 * Represented country data for the requested IP address. The represented
29 * country is used for things like military bases. It is only present when
30 * the represented country differs from the country.
31 *
32 * @property-read \GeoIp2\Record\Traits $traits Data for the traits of the
33 * requested IP address.
34 */
35 class Country extends AbstractModel
36 {
37 protected $continent;
38 protected $country;
39 protected $locales;
40 protected $maxmind;
41 protected $registeredCountry;
42 protected $representedCountry;
43 protected $traits;
44
45 /**
46 * @ignore
47 */
48 public function __construct($raw, $locales = array('en'))
49 {
50 parent::__construct($raw);
51
52 $this->continent = new \GeoIp2\Record\Continent(
53 $this->get('continent'),
54 $locales
55 );
56 $this->country = new \GeoIp2\Record\Country(
57 $this->get('country'),
58 $locales
59 );
60 $this->maxmind = new \GeoIp2\Record\MaxMind($this->get('maxmind'));
61 $this->registeredCountry = new \GeoIp2\Record\Country(
62 $this->get('registered_country'),
63 $locales
64 );
65 $this->representedCountry = new \GeoIp2\Record\RepresentedCountry(
66 $this->get('represented_country'),
67 $locales
68 );
69 $this->traits = new \GeoIp2\Record\Traits($this->get('traits'));
70
71 $this->locales = $locales;
72 }
73 }
74