1 | <?php |
||
26 | class Query implements QueryInterface |
||
27 | { |
||
28 | use ImmutableComponentTrait; |
||
29 | |||
30 | use ImmutableCollectionTrait; |
||
31 | |||
32 | /** |
||
33 | * Key/pair separator character |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected static $separator = '&'; |
||
38 | |||
39 | /** |
||
40 | * Preserve the delimiter |
||
41 | * |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $preserveDelimiter = false; |
||
45 | |||
46 | /** |
||
47 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
48 | * |
||
49 | * @deprecated deprecated since version 4.2 |
||
50 | * |
||
51 | * return a new instance from an array or a traversable object |
||
52 | * |
||
53 | * @param \Traversable|array $data |
||
54 | * |
||
55 | * @return static |
||
56 | */ |
||
57 | public static function createFromArray($data) |
||
61 | |||
62 | /** |
||
63 | * return a new Query instance from an Array or a traversable object |
||
64 | * |
||
65 | * @param \Traversable|array $data |
||
66 | * |
||
67 | * @return static |
||
68 | */ |
||
69 | 108 | public static function createFromPairs($data) |
|
80 | |||
81 | /** |
||
82 | * a new instance |
||
83 | * |
||
84 | * @param string $data |
||
85 | */ |
||
86 | 955 | public function __construct($data = null) |
|
91 | |||
92 | /** |
||
93 | * sanitize the submitted data |
||
94 | * |
||
95 | * @param string $str |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | 955 | protected function validate($str) |
|
108 | |||
109 | /** |
||
110 | * @inheritdoc |
||
111 | */ |
||
112 | 2 | public function __debugInfo() |
|
116 | |||
117 | /** |
||
118 | * @inheritdoc |
||
119 | */ |
||
120 | 12 | public static function __set_state(array $properties) |
|
127 | |||
128 | /** |
||
129 | * Returns the component literal value. |
||
130 | * |
||
131 | * @return null|string |
||
132 | */ |
||
133 | 862 | public function getContent() |
|
141 | |||
142 | /** |
||
143 | * Returns the instance string representation; If the |
||
144 | * instance is not defined an empty string is returned |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | 850 | public function __toString() |
|
152 | |||
153 | /** |
||
154 | * Returns the instance string representation |
||
155 | * with its optional URI delimiters |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | 800 | public function getUriComponent() |
|
168 | |||
169 | /** |
||
170 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
171 | * |
||
172 | * @deprecated deprecated since version 4.2 |
||
173 | * |
||
174 | * Returns an array representation of the query |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | public function toArray() |
||
182 | |||
183 | /** |
||
184 | * Returns an array representation of the query |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 54 | public function getPairs() |
|
192 | |||
193 | /** |
||
194 | * Retrieves a single query parameter. |
||
195 | * |
||
196 | * Retrieves a single query parameter. If the parameter has not been set, |
||
197 | * returns the default value provided. |
||
198 | * |
||
199 | * @param string $offset the parameter name |
||
200 | * @param mixed $default Default value to return if the parameter does not exist. |
||
201 | * |
||
202 | * @return mixed |
||
203 | */ |
||
204 | 9 | public function getValue($offset, $default = null) |
|
214 | |||
215 | /** |
||
216 | * Returns an instance with the specified string |
||
217 | * |
||
218 | * This method MUST retain the state of the current instance, and return |
||
219 | * an instance that contains the modified data |
||
220 | * |
||
221 | * @param string $value |
||
222 | * |
||
223 | * @return static |
||
224 | */ |
||
225 | 240 | public function withContent($value = null) |
|
233 | |||
234 | /** |
||
235 | * DEPRECATION WARNING! This method will be removed in the next major point release |
||
236 | * |
||
237 | * @deprecated deprecated since version 4.2 |
||
238 | * |
||
239 | * @see withContent |
||
240 | * |
||
241 | * Returns an instance with the specified string |
||
242 | * |
||
243 | * This method MUST retain the state of the current instance, and return |
||
244 | * an instance that contains the modified data |
||
245 | * |
||
246 | * @param string $value |
||
247 | * |
||
248 | * @return static |
||
249 | */ |
||
250 | public function modify($value) |
||
254 | |||
255 | /** |
||
256 | * Returns an instance merge with the specified query |
||
257 | * |
||
258 | * This method MUST retain the state of the current instance, and return |
||
259 | * an instance that contains the modified query |
||
260 | * |
||
261 | * @param QueryInterface|string $query the data to be merged |
||
262 | * |
||
263 | * @return static |
||
264 | */ |
||
265 | 24 | public function merge($query) |
|
274 | |||
275 | /** |
||
276 | * Sort the query string by offset, maintaining offset to data correlations. |
||
277 | * |
||
278 | * This method MUST retain the state of the current instance, and return |
||
279 | * an instance that contains the modified query |
||
280 | * |
||
281 | * @param callable|int $sort a PHP sort flag constant or a comparaison function |
||
282 | * which must return an integer less than, equal to, |
||
283 | * or greater than zero if the first argument is |
||
284 | * considered to be respectively less than, equal to, |
||
285 | * or greater than the second. |
||
286 | * |
||
287 | * @return static |
||
288 | */ |
||
289 | 57 | public function ksort($sort = SORT_REGULAR) |
|
300 | |||
301 | /** |
||
302 | * @inheritdoc |
||
303 | */ |
||
304 | 3 | public function hasKey($offset) |
|
311 | |||
312 | /** |
||
313 | * @inheritdoc |
||
314 | */ |
||
315 | 6 | public function keys() |
|
323 | |||
324 | /** |
||
325 | * @inheritdoc |
||
326 | */ |
||
327 | 9 | public function without(array $offsets) |
|
336 | |||
337 | |||
338 | |||
339 | /** |
||
340 | * Return a new instance when needed |
||
341 | * |
||
342 | * @param array $data |
||
343 | * |
||
344 | * @return static |
||
345 | */ |
||
346 | 42 | protected function newCollectionInstance(array $data) |
|
354 | } |
||
355 |