1 | <?php namespace Arcanedev\GeoLocation\Google\Geocoding; |
||
13 | class GeocodingService |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Constants |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | const BASE_URL = 'https://maps.googleapis.com/maps/api/geocode/json'; |
||
21 | |||
22 | /* ----------------------------------------------------------------- |
||
23 | | Properties |
||
24 | | ----------------------------------------------------------------- |
||
25 | */ |
||
26 | |||
27 | /** @var \GuzzleHttp\ClientInterface */ |
||
28 | protected $client; |
||
29 | |||
30 | /** @var string|null */ |
||
31 | protected $key = null; |
||
32 | |||
33 | /* ----------------------------------------------------------------- |
||
34 | | Constructor |
||
35 | | ----------------------------------------------------------------- |
||
36 | */ |
||
37 | |||
38 | /** |
||
39 | * GoogleDistanceMatrix constructor. |
||
40 | * |
||
41 | * @param \GuzzleHttp\ClientInterface $client |
||
42 | */ |
||
43 | 6 | public function __construct(ClientInterface $client) |
|
48 | |||
49 | /* ----------------------------------------------------------------- |
||
50 | | Getters & Setters |
||
51 | | ----------------------------------------------------------------- |
||
52 | */ |
||
53 | |||
54 | /** |
||
55 | * Set the HTTP Client. |
||
56 | * |
||
57 | * @param \GuzzleHttp\ClientInterface $client |
||
58 | * |
||
59 | * @return self |
||
60 | */ |
||
61 | 6 | public function setHttpClient(ClientInterface $client) |
|
67 | |||
68 | /** |
||
69 | * Set the API Key. |
||
70 | * |
||
71 | * @param string $key |
||
72 | * |
||
73 | * @return self |
||
74 | */ |
||
75 | 6 | public function setKey($key) |
|
81 | |||
82 | /* ----------------------------------------------------------------- |
||
83 | | Main Methods |
||
84 | | ----------------------------------------------------------------- |
||
85 | */ |
||
86 | |||
87 | /** |
||
88 | * Get the geocoding response. |
||
89 | * |
||
90 | * @param string $address |
||
91 | * @param array $options |
||
92 | * |
||
93 | * @return \Arcanedev\GeoLocation\Google\Geocoding\GeocodingResponse |
||
94 | */ |
||
95 | 3 | public function geocode($address, array $options = []) |
|
105 | |||
106 | /** |
||
107 | * Prepare the URL query. |
||
108 | * |
||
109 | * @param string $address |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 3 | private function prepareQuery($address) |
|
122 | } |
||
123 |