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 | 5 | public function __construct( |
|
97 | |||
98 | /** |
||
99 | * Returns a new search object based on the base search. |
||
100 | * |
||
101 | * @return Search |
||
102 | */ |
||
103 | 3 | public function newSearch() |
|
107 | |||
108 | /** |
||
109 | * Returns a new search object based on the base reverse. |
||
110 | * |
||
111 | * @return Reverse |
||
112 | */ |
||
113 | 2 | public function newReverse() |
|
117 | |||
118 | /** |
||
119 | * Returns a new search object based on the base lookup. |
||
120 | * |
||
121 | * @return Lookup |
||
122 | */ |
||
123 | 2 | public function newLookup() |
|
127 | |||
128 | /** |
||
129 | * Decode the data returned from the request |
||
130 | * |
||
131 | * @param string $format json or xml |
||
132 | * @param Request $request Request object from Guzzle |
||
133 | * @param ResponseInterface $response Interface response object from Guzzle |
||
134 | * |
||
135 | * @return array|\SimpleXMLElement |
||
136 | * @throws maxh\Nominatim\Exceptions\NominatimException if no format for decode |
||
137 | */ |
||
138 | private function decodeResponse($format, Request $request, ResponseInterface $response) |
||
150 | |||
151 | /** |
||
152 | * Runs the query and returns the result set from Nominatim. |
||
153 | * @param QueryInterface $nRequest The object request to send |
||
154 | * |
||
155 | * @return array The decoded data returned from Nominatim |
||
156 | * @throws \GuzzleHttp\Exception\ClientException if http request is an error |
||
157 | */ |
||
158 | public function find(QueryInterface $nRequest) |
||
175 | |||
176 | /** |
||
177 | * Return the client using by instance |
||
178 | * @return GuzzleHttp\Client |
||
179 | */ |
||
180 | 1 | public function getClient() |
|
184 | } |
||
185 |