1 | <?php |
||
22 | class Nominatim |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Contain url of the current application |
||
27 | * @var string |
||
28 | */ |
||
29 | private $application_url = null; |
||
30 | |||
31 | /** |
||
32 | * Contain http client connection |
||
33 | * @var Client |
||
34 | */ |
||
35 | private $http_client = null; |
||
36 | |||
37 | /** |
||
38 | * The search object which serves as a template for new ones created |
||
39 | * by 'newSearch()' method. |
||
40 | * |
||
41 | * @var Search |
||
42 | */ |
||
43 | private $baseSearch; |
||
44 | |||
45 | /** |
||
46 | * Template for new ones created by 'newReverser()' method. |
||
47 | * @var Reverse |
||
48 | */ |
||
49 | private $baseReverse; |
||
50 | |||
51 | /** |
||
52 | * Template for new ones created by 'newLookup()' method. |
||
53 | * @var Lookup |
||
54 | */ |
||
55 | private $baseLookup; |
||
56 | |||
57 | /** |
||
58 | * Constructor |
||
59 | * @param string $application_url Contain url of the current application |
||
60 | * @param Guzzle\Client|null $http_client Client object from Guzzle |
||
61 | */ |
||
62 | public function __construct( |
||
107 | |||
108 | /** |
||
109 | * Returns a new search object based on the base search. |
||
110 | * |
||
111 | * @return Search |
||
112 | */ |
||
113 | public function newSearch() |
||
117 | |||
118 | /** |
||
119 | * Returns a new search object based on the base reverse. |
||
120 | * |
||
121 | * @return Reverse |
||
122 | */ |
||
123 | public function newReverse() |
||
127 | |||
128 | /** |
||
129 | * Returns a new search object based on the base lookup. |
||
130 | * |
||
131 | * @return Lookup |
||
132 | */ |
||
133 | public function newLookup() |
||
137 | |||
138 | /** |
||
139 | * Decode the data returned from the request |
||
140 | * |
||
141 | * @param string $format json or xml |
||
142 | * @param Request $request Request object from Guzzle |
||
143 | * @param ResponseInterface $response Interface response object from Guzzle |
||
144 | * |
||
145 | * @return array|\SimpleXMLElement |
||
146 | * @throws maxh\Nominatim\Exceptions\NominatimException if no format for decode |
||
147 | */ |
||
148 | private function decodeResponse($format, Request $request, ResponseInterface $response) |
||
163 | |||
164 | /** |
||
165 | * Runs the query and returns the result set from Nominatim. |
||
166 | * @param QueryInterface $nRequest The object request to send |
||
167 | * |
||
168 | * @return array The decoded data returned from Nominatim |
||
169 | * @throws \GuzzleHttp\Exception\ClientException if http request is an error |
||
170 | */ |
||
171 | public function find(QueryInterface $nRequest) |
||
188 | |||
189 | /** |
||
190 | * Return the client using by instance |
||
191 | * @return GuzzleHttp\Client |
||
192 | */ |
||
193 | public function getClient() |
||
197 | |||
198 | } |
||
199 |