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 | public function __construct(array $query = []) |
||
65 | |||
66 | // -- Builder methods ------------------------------------------------------ |
||
67 | |||
68 | /** |
||
69 | * Format returning by the request. |
||
70 | * |
||
71 | * @param string $format The output format for the request |
||
72 | * |
||
73 | * @return maxh\Nominatim\Query |
||
74 | * @throws maxh\Nominatim\Exceptions\InvalidParameterException if format is not supported |
||
75 | */ |
||
76 | public function format($format) |
||
89 | |||
90 | /** |
||
91 | * Preferred language order for showing search results, overrides the value |
||
92 | * specified in the "Accept-Language" HTTP header. Either uses standard |
||
93 | * rfc2616 accept-language string or a simple comma separated list of |
||
94 | * language codes. |
||
95 | * |
||
96 | * @param string $language Preferred language order for showing search results, overrides the value specified in the "Accept-Language" HTTP header. |
||
97 | * Either uses standard rfc2616 accept-language string or a simple comma separated list of language codes. |
||
98 | * |
||
99 | * @return maxh\Nominatim\Query |
||
100 | */ |
||
101 | public function language($language) |
||
107 | |||
108 | /** |
||
109 | * Include a breakdown of the address into elements. |
||
110 | * |
||
111 | * @param boolean $details |
||
112 | * |
||
113 | * @return maxh\Nominatim\Query |
||
114 | */ |
||
115 | public function addressDetails($details = true) |
||
121 | |||
122 | /** |
||
123 | * If you are making large numbers of request please include a valid email address or alternatively include your email address as part of the User-Agent string. |
||
124 | * This information will be kept confidential and only used to contact you in the event of a problem, see Usage Policy for more details. |
||
125 | * |
||
126 | * @param string $email Address mail |
||
127 | * |
||
128 | * @return maxh\Nominatim\Query |
||
129 | */ |
||
130 | public function email($email) |
||
136 | |||
137 | /** |
||
138 | * Output format for the geometry of results |
||
139 | * |
||
140 | * @param string $polygon |
||
141 | * |
||
142 | * @return maxh\Nominatim\Query |
||
143 | * @throws maxh\Nominatim\Exceptions\InvalidParameterException if polygon format is not supported |
||
144 | */ |
||
145 | public function polygon($polygon) |
||
156 | |||
157 | /** |
||
158 | * Include additional information in the result if available |
||
159 | * |
||
160 | * @param boolean $tags |
||
161 | * |
||
162 | * @return maxh\Nominatim\Query |
||
163 | */ |
||
164 | public function extraTags($tags = true) |
||
170 | |||
171 | /** |
||
172 | * Include a list of alternative names in the results. |
||
173 | * These may include language variants, references, operator and brand. |
||
174 | * |
||
175 | * @param boolean $details |
||
176 | * |
||
177 | * @return maxh\Nominatim\Query |
||
178 | */ |
||
179 | public function nameDetails($details = true) |
||
185 | |||
186 | /** |
||
187 | * Returns the URL-encoded query. |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | public function getQueryString() |
||
195 | |||
196 | // -- Getters & Setters ---------------------------------------------------- |
||
197 | |||
198 | /** |
||
199 | * Get path |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getPath() |
||
206 | |||
207 | /** |
||
208 | * Get query |
||
209 | * @return array |
||
210 | */ |
||
211 | public function getQuery() |
||
215 | |||
216 | /** |
||
217 | * Get format |
||
218 | * @return string |
||
219 | */ |
||
220 | public function getFormat() |
||
224 | |||
225 | /** |
||
226 | * Set path |
||
227 | * @param string $path Name's path of the service |
||
228 | */ |
||
229 | protected function setPath($path) |
||
233 | |||
234 | /** |
||
235 | * Set query |
||
236 | * @param array $query Parameter of the query |
||
237 | */ |
||
238 | protected function setQuery($query = array()) |
||
242 | |||
243 | /** |
||
244 | * Set format |
||
245 | * @param string $format Format returning by the response |
||
246 | */ |
||
247 | protected function setFormat($format) |
||
251 | |||
252 | } |
||
253 |