Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

   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   * https://dev.maxmind.com/geoip/geoip2/web-services 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   */
  30  class Country extends AbstractModel
  31  {
  32      protected $continent;
  33      protected $country;
  34      protected $locales;
  35      protected $maxmind;
  36      protected $registeredCountry;
  37      protected $representedCountry;
  38      protected $traits;
  39  
  40      /**
  41       * @ignore
  42       *
  43       * @param mixed $raw
  44       * @param mixed $locales
  45       */
  46      public function __construct($raw, $locales = ['en'])
  47      {
  48          parent::__construct($raw);
  49  
  50          $this->continent = new \GeoIp2\Record\Continent(
  51              $this->get('continent'),
  52              $locales
  53          );
  54          $this->country = new \GeoIp2\Record\Country(
  55              $this->get('country'),
  56              $locales
  57          );
  58          $this->maxmind = new \GeoIp2\Record\MaxMind($this->get('maxmind'));
  59          $this->registeredCountry = new \GeoIp2\Record\Country(
  60              $this->get('registered_country'),
  61              $locales
  62          );
  63          $this->representedCountry = new \GeoIp2\Record\RepresentedCountry(
  64              $this->get('represented_country'),
  65              $locales
  66          );
  67          $this->traits = new \GeoIp2\Record\Traits($this->get('traits'));
  68  
  69          $this->locales = $locales;
  70      }
  71  }