Overview

Namespaces

  • GeoIP2
    • Exception
    • Model
    • Record
    • WebService
  • PHP

Classes

  • City
  • CityIspOrg
  • Country
  • Omni
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace GeoIP2\Model;
 4: 
 5: /**
 6:  * This class provides a model for the data returned by the GeoIP2 Country
 7:  * end point.
 8:  *
 9:  * The only difference between the City, City/ISP/Org, and Omni model
10:  * classes is which fields in each record may be populated. See
11:  * http://dev.maxmind.com/geoip/geoip2/web-services more details.
12:  *
13:  * @property \GeoIP2\Record\Continent $continent Continent data for the
14:  * requested IP address.
15:  *
16:  * @property \GeoIP2\Record\Country $country Country data for the requested
17:  * IP address. This object represents the country where MaxMind believes the
18:  * end user is located.
19:  *
20:  * @property \GeoIP2\Record\MaxMind $maxmind Data related to your MaxMind
21:  * account.
22:  *
23:  * @property \GeoIP2\Record\Country $registeredCountry Registered country
24:  * data for the requested IP address. This record represents the country
25:  * where the ISP has registered a given IP block in and may differ from the
26:  * user's country.
27:  *
28:  * @property \GeoIP2\Record\RepresentedCountry $representedCountry
29:  * Represented country data for the requested IP address. The represented
30:  * country is used for things like military bases or embassies. It is only
31:  * present when the represented country differs from the country.
32:  *
33:  * @property \GeoIP2\Record\Traits $traits Data for the traits of the
34:  * requested IP address.
35:  */
36: class Country
37: {
38:     private $continent;
39:     private $country;
40:     private $languages;
41:     private $maxmind;
42:     private $registeredCountry;
43:     private $representedCountry;
44:     private $traits;
45:     private $raw;
46: 
47:     /**
48:      * @ignore
49:      */
50:     public function __construct($raw, $languages)
51:     {
52:         $this->raw = $raw;
53: 
54:         $this->continent = new \GeoIP2\Record\Continent(
55:             $this->get('continent'),
56:             $languages
57:         );
58:         $this->country = new \GeoIP2\Record\Country(
59:             $this->get('country'),
60:             $languages
61:         );
62:         $this->maxmind = new \GeoIP2\Record\MaxMind($this->get('maxmind'));
63:         $this->registeredCountry = new \GeoIP2\Record\Country(
64:             $this->get('registered_country'),
65:             $languages
66:         );
67:         $this->representedCountry = new \GeoIP2\Record\RepresentedCountry(
68:             $this->get('represented_country'),
69:             $languages
70:         );
71:         $this->traits = new \GeoIP2\Record\Traits($this->get('traits'));
72: 
73:         $this->languages = $languages;
74:     }
75: 
76:     /**
77:      * @ignore
78:      */
79:     protected function get($field)
80:     {
81:         return isset($this->raw[$field]) ? $this->raw[$field] : array();
82:     }
83: 
84:     /**
85:      * @ignore
86:      */
87:     public function __get ($attr)
88:     {
89:         if ($attr != "instance" && isset($this->$attr)) {
90:             return $this->$attr;
91:         }
92: 
93:         throw new \RuntimeException("Unknown attribute: $attr");
94:     }
95: }
96: 
API documentation generated by ApiGen 2.8.0