Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

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