Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

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