Added iterface for Reader/Client.

It could use a better name.
This commit is contained in:
Gregory Oschwald 2013-10-02 06:54:03 -07:00
parent c584dbfd6b
commit 167433de0c
3 changed files with 38 additions and 2 deletions

View File

@ -7,6 +7,7 @@ use GeoIp2\Model\City;
use GeoIp2\Model\CityIspOrg;
use GeoIp2\Model\Country;
use GeoIp2\Model\Omni;
use GeoIp2\ProviderInterface;
use MaxMind\Db\Reader as DbReader;
/**
@ -38,7 +39,7 @@ use MaxMind\Db\Reader as DbReader;
* will be thrown.
*
*/
class Reader
class Reader implements ProviderInterface
{
private $dbReader;
private $languages;

View File

@ -0,0 +1,34 @@
<?php
namespace GeoIp2;
interface ProviderInterface
{
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return A Country model for the requested IP address.
*/
public function country($ipAddress);
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return A City model for the requested IP address.
*/
public function city($ipAddress);
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return A CityIspOrg model for the requested IP address.
*/
public function cityIspOrg($ipAddress);
/**
* @param ipAddress
* IPv4 or IPv6 address to lookup.
* @return An Omni model for the requested IP address.
*/
public function omni($ipAddress);
}

View File

@ -12,6 +12,7 @@ use GeoIp2\Model\City;
use GeoIp2\Model\CityIspOrg;
use GeoIp2\Model\Country;
use GeoIp2\Model\Omni;
use GeoIp2\ProviderInterface;
use Guzzle\Http\Client as GuzzleClient;
use Guzzle\Common\Exception\RuntimeException;
use Guzzle\Http\Exception\ClientErrorResponseException;
@ -48,7 +49,7 @@ use Guzzle\Http\Exception\ServerErrorResponseException;
*
* If the request fails, the client class throws an exception.
*/
class Client
class Client implements ProviderInterface
{
private $userId;
private $licenseKey;