| Total Complexity | 5 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class GeoLocation |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The current driver. |
||
| 12 | * |
||
| 13 | * @var Driver |
||
| 14 | */ |
||
| 15 | protected $driver; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Constructor. |
||
| 19 | * |
||
| 20 | * @throws DriverDoesNotExistException |
||
| 21 | */ |
||
| 22 | public function __construct() |
||
| 23 | { |
||
| 24 | $driver = $this->getDriver(); |
||
| 25 | |||
| 26 | $this->setDriver($driver); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Creates the selected driver instance and sets the driver property. |
||
| 31 | * |
||
| 32 | * @param Driver $driver |
||
| 33 | * |
||
| 34 | * @return void |
||
| 35 | */ |
||
| 36 | public function setDriver(Driver $driver) |
||
| 37 | { |
||
| 38 | $this->driver = $driver; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Retrieve the users geo-location. |
||
| 43 | * |
||
| 44 | * @param string $ip |
||
| 45 | * |
||
| 46 | * @return \Psonrie\GeoLocation\Response|bool |
||
| 47 | */ |
||
| 48 | public function get($ip) |
||
| 49 | { |
||
| 50 | return $this->driver->get($ip); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Returns the default driver. |
||
| 55 | * |
||
| 56 | * @return Driver|mixed |
||
| 57 | * |
||
| 58 | * @throws DriverDoesNotExistException |
||
| 59 | */ |
||
| 60 | protected function getDriver() |
||
| 69 | } |
||
| 70 | } |
||
| 71 |