1 | <?php |
||
27 | class Query implements QueryInterface |
||
28 | { |
||
29 | use ImmutableComponentTrait; |
||
30 | |||
31 | use ImmutableCollectionTrait; |
||
32 | |||
33 | /** |
||
34 | * Key/pair separator character |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected static $separator = '&'; |
||
39 | |||
40 | /** |
||
41 | * Preserve the delimiter |
||
42 | * |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $preserveDelimiter = false; |
||
46 | |||
47 | /** |
||
48 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
49 | * |
||
50 | * @deprecated deprecated since version 4.2 |
||
51 | * |
||
52 | * return a new instance from an array or a traversable object |
||
53 | * |
||
54 | * @param \Traversable|array $data |
||
55 | * |
||
56 | * @return static |
||
57 | */ |
||
58 | public static function createFromArray($data) |
||
62 | |||
63 | /** |
||
64 | * return a new Query instance from an Array or a traversable object |
||
65 | * |
||
66 | * @param \Traversable|array $data |
||
67 | * |
||
68 | * @return static |
||
69 | 108 | */ |
|
70 | public static function createFromPairs($data) |
||
81 | |||
82 | /** |
||
83 | * a new instance |
||
84 | * |
||
85 | * @param string $data |
||
86 | 967 | */ |
|
87 | public function __construct($data = null) |
||
92 | |||
93 | /** |
||
94 | * sanitize the submitted data |
||
95 | * |
||
96 | * @param string $str |
||
97 | * |
||
98 | * @return array |
||
99 | 967 | */ |
|
100 | protected function validate($str) |
||
110 | |||
111 | /** |
||
112 | 2 | * Filter the encoded query string |
|
113 | * |
||
114 | 2 | * @param string $str the encoded query |
|
115 | * |
||
116 | * @throws InvalidArgumentException If the encoded query is invalid |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 12 | protected function filterEncodedQuery($str) |
|
131 | |||
132 | /** |
||
133 | 880 | * @inheritdoc |
|
134 | */ |
||
135 | 880 | public function __debugInfo() |
|
139 | 664 | ||
140 | /** |
||
141 | * @inheritdoc |
||
142 | */ |
||
143 | public static function __set_state(array $properties) |
||
150 | 874 | ||
151 | /** |
||
152 | * Returns the component literal value. |
||
153 | * |
||
154 | * @return null|string |
||
155 | */ |
||
156 | public function getContent() |
||
164 | |||
165 | /** |
||
166 | 483 | * Returns the instance string representation; If the |
|
167 | * instance is not defined an empty string is returned |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function __toString() |
||
175 | |||
176 | /** |
||
177 | * Returns the instance string representation |
||
178 | * with its optional URI delimiters |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getUriComponent() |
||
191 | |||
192 | /** |
||
193 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
194 | * |
||
195 | * @deprecated deprecated since version 4.2 |
||
196 | * |
||
197 | * Returns an array representation of the query |
||
198 | * |
||
199 | * @return array |
||
200 | */ |
||
201 | public function toArray() |
||
205 | |||
206 | 9 | /** |
|
207 | 9 | * Returns an array representation of the query |
|
208 | 9 | * |
|
209 | 3 | * @return array |
|
210 | */ |
||
211 | public function getPairs() |
||
215 | |||
216 | /** |
||
217 | * Retrieves a single query parameter. |
||
218 | * |
||
219 | * Retrieves a single query parameter. If the parameter has not been set, |
||
220 | * returns the default value provided. |
||
221 | * |
||
222 | * @param string $offset the parameter name |
||
223 | * @param mixed $default Default value to return if the parameter does not exist. |
||
224 | * |
||
225 | 240 | * @return mixed |
|
226 | */ |
||
227 | 240 | public function getValue($offset, $default = null) |
|
237 | |||
238 | /** |
||
239 | * Returns an instance with the specified string |
||
240 | * |
||
241 | * This method MUST retain the state of the current instance, and return |
||
242 | * an instance that contains the modified data |
||
243 | * |
||
244 | * @param string $value |
||
245 | * |
||
246 | * @return static |
||
247 | */ |
||
248 | public function withContent($value = null) |
||
256 | |||
257 | /** |
||
258 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
259 | * |
||
260 | * @deprecated deprecated since version 4.2 |
||
261 | * |
||
262 | * @see withContent |
||
263 | * |
||
264 | * Returns an instance with the specified string |
||
265 | 24 | * |
|
266 | * This method MUST retain the state of the current instance, and return |
||
267 | 24 | * an instance that contains the modified data |
|
268 | 24 | * |
|
269 | 3 | * @param string $value |
|
270 | * |
||
271 | * @return static |
||
272 | 21 | */ |
|
273 | public function modify($value) |
||
277 | |||
278 | /** |
||
279 | * Returns an instance merge with the specified query |
||
280 | * |
||
281 | * This method MUST retain the state of the current instance, and return |
||
282 | * an instance that contains the modified query |
||
283 | * |
||
284 | * @param QueryInterface|string $query the data to be merged |
||
285 | * |
||
286 | * @return static |
||
287 | */ |
||
288 | public function merge($query) |
||
297 | |||
298 | 12 | /** |
|
299 | * Sort the query string by offset, maintaining offset to data correlations. |
||
300 | * |
||
301 | * This method MUST retain the state of the current instance, and return |
||
302 | * an instance that contains the modified query |
||
303 | * |
||
304 | 3 | * @param callable|int $sort a PHP sort flag constant or a comparaison function |
|
305 | * which must return an integer less than, equal to, |
||
306 | 3 | * or greater than zero if the first argument is |
|
307 | 3 | * considered to be respectively less than, equal to, |
|
308 | * or greater than the second. |
||
309 | 3 | * |
|
310 | * @return static |
||
311 | */ |
||
312 | public function ksort($sort = SORT_REGULAR) |
||
323 | |||
324 | /** |
||
325 | * @inheritdoc |
||
326 | */ |
||
327 | 9 | public function hasKey($offset) |
|
334 | 9 | ||
335 | /** |
||
336 | * @inheritdoc |
||
337 | */ |
||
338 | public function keys() |
||
346 | 42 | ||
347 | /** |
||
348 | 42 | * @inheritdoc |
|
349 | 15 | */ |
|
350 | public function without(array $offsets) |
||
359 | |||
360 | |||
361 | |||
362 | /** |
||
363 | * Return a new instance when needed |
||
364 | * |
||
365 | * @param array $data |
||
366 | * |
||
367 | * @return static |
||
368 | */ |
||
369 | protected function newCollectionInstance(array $data) |
||
377 | } |
||
378 |