Expanded examples plus small bug fix
This commit is contained in:
parent
22babda1c9
commit
cdf75ec505
60
README.md
60
README.md
|
@ -87,7 +87,7 @@ is thrown. If the database is invalid or corrupt, a
|
||||||
|
|
||||||
See the API documentation for more details.
|
See the API documentation for more details.
|
||||||
|
|
||||||
### Example ###
|
### City Example ###
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
|
@ -118,6 +118,64 @@ print($record->location->longitude . "\n"); // -93.2323
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Connection-Type Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Connection-Type.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->connectionType('128.101.101.101');
|
||||||
|
|
||||||
|
print($record->connectionType . "\n"); // 'Corporate'
|
||||||
|
print($record->ipAddress . "\n"); // '128.101.101.101'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Domain Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-Domain.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->domain('128.101.101.101');
|
||||||
|
|
||||||
|
print($record->domain . "\n"); // 'umn.edu'
|
||||||
|
print($record->ipAddress . "\n"); // '128.101.101.101'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### ISP Example ###
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
// This creates the Reader object, which should be reused across
|
||||||
|
// lookups.
|
||||||
|
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-ISP.mmdb');
|
||||||
|
|
||||||
|
$record = $reader->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 ##
|
## Web Service Client ##
|
||||||
|
|
||||||
### Usage ###
|
### Usage ###
|
||||||
|
|
|
@ -24,7 +24,7 @@ abstract class AbstractModel implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
protected function get($field)
|
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)
|
public function __get($attr)
|
||||||
{
|
{
|
||||||
if ($attr != "instance" && isset($this->$attr)) {
|
if ($attr != "instance" && property_exists($this, $attr)) {
|
||||||
return $this->$attr;
|
return $this->$attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ abstract class AbstractRecord implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public function __construct($record)
|
public function __construct($record)
|
||||||
{
|
{
|
||||||
$this->record = $record;
|
$this->record = isset($record) ? $record : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user