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   * @ignore
   7   */
   8  abstract class AbstractModel implements \JsonSerializable
   9  {
  10      protected $raw;
  11  
  12      /**
  13       * @ignore
  14       *
  15       * @param mixed $raw
  16       */
  17      public function __construct($raw)
  18      {
  19          $this->raw = $raw;
  20      }
  21  
  22      /**
  23       * @ignore
  24       *
  25       * @param mixed $field
  26       */
  27      protected function get($field)
  28      {
  29          if (isset($this->raw[$field])) {
  30              return $this->raw[$field];
  31          }
  32          if (preg_match('/^is_/', $field)) {
  33              return false;
  34          }
  35  
  36          return null;
  37      }
  38  
  39      /**
  40       * @ignore
  41       *
  42       * @param mixed $attr
  43       */
  44      public function __get($attr)
  45      {
  46          if ($attr !== 'instance' && property_exists($this, $attr)) {
  47              return $this->$attr;
  48          }
  49  
  50          throw new \RuntimeException("Unknown attribute: $attr");
  51      }
  52  
  53      /**
  54       * @ignore
  55       *
  56       * @param mixed $attr
  57       */
  58      public function __isset($attr)
  59      {
  60          return $attr !== 'instance' && isset($this->$attr);
  61      }
  62  
  63      public function jsonSerialize()
  64      {
  65          return $this->raw;
  66      }
  67  }