Search moodle.org's
Developer Documentation

See Release Notes

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

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

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace GeoIp2\Model;
   6  
   7  use GeoIp2\Util;
   8  
   9  /**
  10   * This class provides the GeoIP2 Domain model.
  11   *
  12   * @property-read string|null $domain The second level domain associated with the
  13   *     IP address. This will be something like "example.com" or
  14   *     "example.co.uk", not "foo.example.com".
  15   * @property-read string $ipAddress The IP address that the data in the model is
  16   *     for.
  17   * @property-read string $network The network in CIDR notation associated with
  18   *      the record. In particular, this is the largest network where all of the
  19   *      fields besides $ipAddress have the same value.
  20   */
  21  class Domain extends AbstractModel
  22  {
  23      /**
  24       * @var string|null
  25       */
  26      protected $domain;
  27  
  28      /**
  29       * @var string
  30       */
  31      protected $ipAddress;
  32  
  33      /**
  34       * @var string
  35       */
  36      protected $network;
  37  
  38      /**
  39       * @ignore
  40       */
  41      public function __construct(array $raw)
  42      {
  43          parent::__construct($raw);
  44  
  45          $this->domain = $this->get('domain');
  46          $ipAddress = $this->get('ip_address');
  47          $this->ipAddress = $ipAddress;
  48          $this->network = Util::cidr($ipAddress, $this->get('prefix_len'));
  49      }
  50  }