diff --git a/README.md b/README.md index 6c753f1..c558801 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ is thrown. If the database is invalid or corrupt, a See the API documentation for more details. -### Example ### +### City Example ### ```php location->longitude . "\n"); // -93.2323 ``` +### Connection-Type Example ### + +```php +connectionType('128.101.101.101'); + +print($record->connectionType . "\n"); // 'Corporate' +print($record->ipAddress . "\n"); // '128.101.101.101' + +``` + +### Domain Example ### + +```php +domain('128.101.101.101'); + +print($record->domain . "\n"); // 'umn.edu' +print($record->ipAddress . "\n"); // '128.101.101.101' + +``` + +### ISP Example ### + +```php +isp('128.101.101.101'); + +print($record->autonomousSystemNumber . "\n"); // 217 +print($record->autonomousSystemOrganization . "\n"); // 'University of Minnesota' +print($record->isp . "\n"); // 'University of Minnesota' +print($record->organization . "\n"); // 'University of Minnesota' + +print($record->ipAddress . "\n"); // '128.101.101.101' + +``` + ## Web Service Client ## ### Usage ### diff --git a/src/GeoIp2/Model/AbstractModel.php b/src/GeoIp2/Model/AbstractModel.php index fddf625..69a86ee 100644 --- a/src/GeoIp2/Model/AbstractModel.php +++ b/src/GeoIp2/Model/AbstractModel.php @@ -24,7 +24,7 @@ abstract class AbstractModel implements \JsonSerializable */ protected function get($field) { - return isset($this->raw[$field]) ? $this->raw[$field] : array(); + return isset($this->raw[$field]) ? $this->raw[$field] : null; } /** @@ -32,7 +32,7 @@ abstract class AbstractModel implements \JsonSerializable */ public function __get($attr) { - if ($attr != "instance" && isset($this->$attr)) { + if ($attr != "instance" && property_exists($this, $attr)) { return $this->$attr; } diff --git a/src/GeoIp2/Record/AbstractRecord.php b/src/GeoIp2/Record/AbstractRecord.php index 7210aff..b81bfea 100644 --- a/src/GeoIp2/Record/AbstractRecord.php +++ b/src/GeoIp2/Record/AbstractRecord.php @@ -11,7 +11,7 @@ abstract class AbstractRecord implements \JsonSerializable */ public function __construct($record) { - $this->record = $record; + $this->record = isset($record) ? $record : array(); } /**