1 | <?php |
||
16 | class Query implements QueryInterface |
||
17 | { |
||
18 | /** |
||
19 | * Contain the path of the request |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $path; |
||
23 | |||
24 | /** |
||
25 | * Contain the query for request |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $query = []; |
||
29 | |||
30 | /** |
||
31 | * Contain the format for decode data returning by the request |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $format; |
||
35 | |||
36 | /** |
||
37 | * Output format accepted |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $accepteFormat = ['xml', 'json']; |
||
41 | |||
42 | /** |
||
43 | * Output polygon format accepted |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $polygon = ['geojson', 'kml', 'svg', 'text']; |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Constuctor |
||
51 | * @param array $query Default value for this query |
||
52 | */ |
||
53 | 5 | public function __construct(array $query = []) |
|
63 | |||
64 | // -- Builder methods ------------------------------------------------------ |
||
65 | |||
66 | /** |
||
67 | * Format returning by the request. |
||
68 | * |
||
69 | * @param string $format The output format for the request |
||
70 | * |
||
71 | * @return maxh\Nominatim\Query |
||
72 | * @throws maxh\Nominatim\Exceptions\InvalidParameterException if format is not supported |
||
73 | */ |
||
74 | 1 | public function format($format) |
|
86 | |||
87 | /** |
||
88 | * Preferred language order for showing search results, overrides the value |
||
89 | * specified in the "Accept-Language" HTTP header. Either uses standard |
||
90 | * rfc2616 accept-language string or a simple comma separated list of |
||
91 | * language codes. |
||
92 | * |
||
93 | * @param string $language Preferred language order for showing search results, overrides the value |
||
94 | * specified in the "Accept-Language" HTTP header. Either uses standard rfc2616 |
||
95 | * accept-language string or a simple comma separated list of language codes. |
||
96 | * |
||
97 | * @return maxh\Nominatim\Query |
||
98 | */ |
||
99 | public function language($language) |
||
105 | |||
106 | /** |
||
107 | * Include a breakdown of the address into elements. |
||
108 | * |
||
109 | * @param boolean $details |
||
110 | * |
||
111 | * @return maxh\Nominatim\Query |
||
112 | */ |
||
113 | 1 | public function addressDetails($details = true) |
|
119 | |||
120 | /** |
||
121 | * If you are making large numbers of request please include a valid email address or alternatively include your |
||
122 | * email address as part of the User-Agent string. This information will be kept confidential and only used to |
||
123 | * contact you in the event of a problem, see Usage Policy for more details. |
||
124 | * |
||
125 | * @param string $email Address mail |
||
126 | * |
||
127 | * @return maxh\Nominatim\Query |
||
128 | */ |
||
129 | public function email($email) |
||
135 | |||
136 | /** |
||
137 | * Output format for the geometry of results |
||
138 | * |
||
139 | * @param string $polygon |
||
140 | * |
||
141 | * @return maxh\Nominatim\Query |
||
142 | * @throws maxh\Nominatim\Exceptions\InvalidParameterException if polygon format is not supported |
||
143 | */ |
||
144 | public function polygon($polygon) |
||
154 | |||
155 | /** |
||
156 | * Include additional information in the result if available |
||
157 | * |
||
158 | * @param boolean $tags |
||
159 | * |
||
160 | * @return maxh\Nominatim\Query |
||
161 | */ |
||
162 | public function extraTags($tags = true) |
||
168 | |||
169 | /** |
||
170 | * Include a list of alternative names in the results. |
||
171 | * These may include language variants, references, operator and brand. |
||
172 | * |
||
173 | * @param boolean $details |
||
174 | * |
||
175 | * @return maxh\Nominatim\Query |
||
176 | */ |
||
177 | public function nameDetails($details = true) |
||
183 | |||
184 | /** |
||
185 | * Returns the URL-encoded query. |
||
186 | * |
||
187 | * @return string |
||
188 | */ |
||
189 | 4 | public function getQueryString() |
|
193 | |||
194 | // -- Getters & Setters ---------------------------------------------------- |
||
195 | |||
196 | /** |
||
197 | * Get path |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getPath() |
||
204 | |||
205 | /** |
||
206 | * Get query |
||
207 | * @return array |
||
208 | */ |
||
209 | 4 | public function getQuery() |
|
213 | |||
214 | /** |
||
215 | * Get format |
||
216 | * @return string |
||
217 | */ |
||
218 | public function getFormat() |
||
222 | |||
223 | /** |
||
224 | * Set path |
||
225 | * @param string $path Name's path of the service |
||
226 | */ |
||
227 | 5 | protected function setPath($path) |
|
231 | |||
232 | /** |
||
233 | * Set query |
||
234 | * @param array $query Parameter of the query |
||
235 | */ |
||
236 | 5 | protected function setQuery($query = array()) |
|
240 | |||
241 | /** |
||
242 | * Set format |
||
243 | * @param string $format Format returning by the response |
||
244 | */ |
||
245 | 5 | protected function setFormat($format) |
|
249 | } |
||
250 |