1 | <?php namespace Arcanedev\GeoIP\Drivers; |
||
13 | abstract class AbstractDriver implements GeoIPDriver |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * Driver options. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $options = []; |
||
26 | |||
27 | /* ----------------------------------------------------------------- |
||
28 | | Constructor |
||
29 | | ----------------------------------------------------------------- |
||
30 | */ |
||
31 | |||
32 | /** |
||
33 | * AbstractDriver constructor. |
||
34 | * |
||
35 | * @param array $options |
||
36 | */ |
||
37 | 45 | public function __construct(array $options = []) |
|
42 | |||
43 | /* ----------------------------------------------------------------- |
||
44 | | Main Methods |
||
45 | | ----------------------------------------------------------------- |
||
46 | */ |
||
47 | |||
48 | /** |
||
49 | * Init the driver. |
||
50 | */ |
||
51 | abstract protected function init(); |
||
52 | |||
53 | /** |
||
54 | * Update the driver. |
||
55 | * |
||
56 | * @return bool |
||
57 | * |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | public function update() |
||
66 | |||
67 | /* ----------------------------------------------------------------- |
||
68 | | Other Methods |
||
69 | | ----------------------------------------------------------------- |
||
70 | */ |
||
71 | |||
72 | /** |
||
73 | * Get option value. |
||
74 | * |
||
75 | * @param string $key |
||
76 | * @param mixed $default |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | 18 | protected function getOption($key, $default = null) |
|
84 | |||
85 | /** |
||
86 | * Hydrate the location entity. |
||
87 | * |
||
88 | * @param array $attributes |
||
89 | * |
||
90 | * @return \Arcanedev\GeoIP\Location |
||
91 | */ |
||
92 | 12 | protected function hydrate(array $attributes = []) |
|
96 | } |
||
97 |