AuthorityInterface.php
2 years ago
DataPathInterface.php
2 years ago
DomainHostInterface.php
2 years ago
FragmentInterface.php
2 years ago
HostInterface.php
2 years ago
IpHostInterface.php
2 years ago
PathInterface.php
2 years ago
PortInterface.php
2 years ago
QueryInterface.php
2 years ago
SegmentedPathInterface.php
2 years ago
UriComponentInterface.php
2 years ago
UriException.php
2 years ago
UriInterface.php
2 years ago
UserInfoInterface.php
2 years ago
QueryInterface.php
207 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * League.Uri (https://uri.thephpleague.com) |
| 5 | * |
| 6 | * (c) Ignace Nyamagana Butera <nyamsprod@gmail.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | declare (strict_types=1); |
| 12 | namespace IAWPSCOPED\League\Uri\Contracts; |
| 13 | |
| 14 | /** |
| 15 | * @extends \IteratorAggregate<array{0:string, 1:string|null}> |
| 16 | * @internal |
| 17 | */ |
| 18 | interface QueryInterface extends \Countable, \IteratorAggregate, UriComponentInterface |
| 19 | { |
| 20 | /** |
| 21 | * Returns the query separator. |
| 22 | */ |
| 23 | public function getSeparator() : string; |
| 24 | /** |
| 25 | * Returns the number of key/value pairs present in the object. |
| 26 | */ |
| 27 | public function count() : int; |
| 28 | /** |
| 29 | * Returns an iterator allowing to go through all key/value pairs contained in this object. |
| 30 | * |
| 31 | * The pair is represented as an array where the first value is the pair key |
| 32 | * and the second value the pair value. |
| 33 | * |
| 34 | * The key of each pair is a string |
| 35 | * The value of each pair is a scalar or the null value |
| 36 | * |
| 37 | * @return \Iterator<int, array{0:string, 1:string|null}> |
| 38 | */ |
| 39 | public function getIterator() : \Iterator; |
| 40 | /** |
| 41 | * Returns an iterator allowing to go through all key/value pairs contained in this object. |
| 42 | * |
| 43 | * The return type is as a Iterator where its offset is the pair key and its value the pair value. |
| 44 | * |
| 45 | * The key of each pair is a string |
| 46 | * The value of each pair is a scalar or the null value |
| 47 | * |
| 48 | * @return iterable<string, string|null> |
| 49 | */ |
| 50 | public function pairs() : iterable; |
| 51 | /** |
| 52 | * Tells whether a pair with a specific name exists. |
| 53 | * |
| 54 | * @see https://url.spec.whatwg.org/#dom-urlsearchparams-has |
| 55 | */ |
| 56 | public function has(string $key) : bool; |
| 57 | /** |
| 58 | * Returns the first value associated to the given pair name. |
| 59 | * |
| 60 | * If no value is found null is returned |
| 61 | * |
| 62 | * @see https://url.spec.whatwg.org/#dom-urlsearchparams-get |
| 63 | */ |
| 64 | public function get(string $key) : ?string; |
| 65 | /** |
| 66 | * Returns all the values associated to the given pair name as an array or all |
| 67 | * the instance pairs. |
| 68 | * |
| 69 | * If no value is found an empty array is returned |
| 70 | * |
| 71 | * @see https://url.spec.whatwg.org/#dom-urlsearchparams-getall |
| 72 | * |
| 73 | * @return array<int, string|null> |
| 74 | */ |
| 75 | public function getAll(string $key) : array; |
| 76 | /** |
| 77 | * Returns the store PHP variables as elements of an array. |
| 78 | * |
| 79 | * The result is similar as PHP parse_str when used with its |
| 80 | * second argument with the difference that variable names are |
| 81 | * not mangled. |
| 82 | * |
| 83 | * If a key is submitted it will returns the value attached to it or null |
| 84 | * |
| 85 | * @see http://php.net/parse_str |
| 86 | * @see https://wiki.php.net/rfc/on_demand_name_mangling |
| 87 | * |
| 88 | * @param ?string $key |
| 89 | * @return mixed the collection of stored PHP variables or the empty array if no input is given, |
| 90 | * the single value of a stored PHP variable or null if the variable is not present in the collection |
| 91 | */ |
| 92 | public function params(?string $key = null); |
| 93 | /** |
| 94 | * Returns the RFC1738 encoded query. |
| 95 | */ |
| 96 | public function toRFC1738() : ?string; |
| 97 | /** |
| 98 | * Returns the RFC3986 encoded query. |
| 99 | * |
| 100 | * @see ::getContent |
| 101 | */ |
| 102 | public function toRFC3986() : ?string; |
| 103 | /** |
| 104 | * Returns an instance with a different separator. |
| 105 | * |
| 106 | * This method MUST retain the state of the current instance, and return |
| 107 | * an instance that contains the query component with a different separator |
| 108 | */ |
| 109 | public function withSeparator(string $separator) : self; |
| 110 | /** |
| 111 | * Sorts the query string by offset, maintaining offset to data correlations. |
| 112 | * |
| 113 | * This method MUST retain the state of the current instance, and return |
| 114 | * an instance that contains the modified query |
| 115 | * |
| 116 | * @see https://url.spec.whatwg.org/#dom-urlsearchparams-sort |
| 117 | */ |
| 118 | public function sort() : self; |
| 119 | /** |
| 120 | * Returns an instance without duplicate key/value pair. |
| 121 | * |
| 122 | * This method MUST retain the state of the current instance, and return |
| 123 | * an instance that contains the query component normalized by removing |
| 124 | * duplicate pairs whose key/value are the same. |
| 125 | */ |
| 126 | public function withoutDuplicates() : self; |
| 127 | /** |
| 128 | * Returns an instance without empty key/value where the value is the null value. |
| 129 | * |
| 130 | * This method MUST retain the state of the current instance, and return |
| 131 | * an instance that contains the query component normalized by removing |
| 132 | * empty pairs. |
| 133 | * |
| 134 | * A pair is considered empty if its value is equal to the null value |
| 135 | */ |
| 136 | public function withoutEmptyPairs() : self; |
| 137 | /** |
| 138 | * Returns an instance where numeric indices associated to PHP's array like key are removed. |
| 139 | * |
| 140 | * This method MUST retain the state of the current instance, and return |
| 141 | * an instance that contains the query component normalized so that numeric indexes |
| 142 | * are removed from the pair key value. |
| 143 | * |
| 144 | * ie.: toto[3]=bar[3]&foo=bar becomes toto[]=bar[3]&foo=bar |
| 145 | */ |
| 146 | public function withoutNumericIndices() : self; |
| 147 | /** |
| 148 | * Returns an instance with the a new key/value pair added to it. |
| 149 | * |
| 150 | * This method MUST retain the state of the current instance, and return |
| 151 | * an instance that contains the modified query |
| 152 | * |
| 153 | * If the pair already exists the value will replace the existing value. |
| 154 | * |
| 155 | * @see https://url.spec.whatwg.org/#dom-urlsearchparams-set |
| 156 | * |
| 157 | * @param ?string $value |
| 158 | */ |
| 159 | public function withPair(string $key, ?string $value) : self; |
| 160 | /** |
| 161 | * Returns an instance with the new pairs set to it. |
| 162 | * |
| 163 | * This method MUST retain the state of the current instance, and return |
| 164 | * an instance that contains the modified query |
| 165 | * |
| 166 | * @see ::withPair |
| 167 | */ |
| 168 | public function merge(string $query) : self; |
| 169 | /** |
| 170 | * Returns an instance without the specified keys. |
| 171 | * |
| 172 | * This method MUST retain the state of the current instance, and return |
| 173 | * an instance that contains the modified component |
| 174 | * |
| 175 | * @param string ...$keys |
| 176 | */ |
| 177 | public function withoutPair(string ...$keys) : self; |
| 178 | /** |
| 179 | * Returns a new instance with a specified key/value pair appended as a new pair. |
| 180 | * |
| 181 | * This method MUST retain the state of the current instance, and return |
| 182 | * an instance that contains the modified query |
| 183 | * |
| 184 | * @param ?string $value |
| 185 | */ |
| 186 | public function appendTo(string $key, ?string $value) : self; |
| 187 | /** |
| 188 | * Returns an instance with the new pairs appended to it. |
| 189 | * |
| 190 | * This method MUST retain the state of the current instance, and return |
| 191 | * an instance that contains the modified query |
| 192 | * |
| 193 | * If the pair already exists the value will be added to it. |
| 194 | */ |
| 195 | public function append(string $query) : self; |
| 196 | /** |
| 197 | * Returns an instance without the specified params. |
| 198 | * |
| 199 | * This method MUST retain the state of the current instance, and return |
| 200 | * an instance that contains the modified component without PHP's value. |
| 201 | * PHP's mangled is not taken into account. |
| 202 | * |
| 203 | * @param string ...$keys |
| 204 | */ |
| 205 | public function withoutParam(string ...$keys) : self; |
| 206 | } |
| 207 |