Overview

Namespaces

  • GeoIP2
    • Exception
    • Model
    • Record
    • WebService
  • PHP

Classes

  • AbstractPlaceRecord
  • AbstractRecord
  • City
  • Continent
  • Country
  • Location
  • MaxMind
  • Postal
  • RepresentedCountry
  • Subdivision
  • Traits
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace GeoIP2\Record;
 4: 
 5: abstract class AbstractRecord
 6: {
 7:     private $record;
 8: 
 9:     /**
10:      * @ignore
11:      */
12:     public function __construct($record)
13:     {
14:         $this->record = $record;
15:     }
16: 
17:     /**
18:      * @ignore
19:      */
20:     public function __get($attr)
21:     {
22:         $valid = in_array($attr, $this->validAttributes);
23:         // XXX - kind of ugly but greatly reduces boilerplate code
24:         $key = strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
25: 
26:         if ($valid && isset($this->record[$key])) {
27:             return $this->record[$key];
28:         } elseif ($valid) {
29:             return null;
30:         } else {
31:             throw new \RuntimeException("Unknown attribute: $attr");
32:         }
33:     }
34: }
35: 
API documentation generated by ApiGen 2.8.0