QueryInterface
extends
Countable, IteratorAggregate, UriComponentInterface
in
Tags
Table of Contents
Methods
- __toString() : string
- Returns the instance string representation.
- append() : self
- Returns an instance with the new pairs appended to it.
- appendTo() : self
- Returns a new instance with a specified key/value pair appended as a new pair.
- count() : int
- Returns the number of key/value pairs present in the object.
- get() : string|null
- Returns the first value associated to the given pair name.
- getAll() : array<int, string|null>
- Returns all the values associated to the given pair name as an array or all the instance pairs.
- getIterator() : Iterator<int, array{0: string, 1: string|null}>
- Returns an iterator allowing to go through all key/value pairs contained in this object.
- getSeparator() : non-empty-string
- Returns the query separator.
- getUriComponent() : string
- Returns the instance string representation with its optional URI delimiters.
- has() : bool
- Tells whether a list of pair with a specific key exists.
- hasParameter() : bool
- Tells whether a list of variable with specific names exists.
- jsonSerialize() : string|null
- Returns the instance json representation.
- merge() : self
- Returns an instance with the new pairs set to it.
- pairs() : iterable<string, string|null>
- Returns an iterator allowing to go through all key/value pairs contained in this object.
- parameter() : mixed
- Returns the value attached to the specific key.
- parameters() : array<string|int, mixed>
- Returns the store PHP variables as elements of an array.
- sort() : self
- Sorts the query string by offset, maintaining offset to data correlations.
- toRFC1738() : string|null
- Returns the RFC1738 encoded query.
- toString() : string
- Returns the instance string representation.
- value() : string|null
- Returns the instance string representation.
- withoutDuplicates() : self
- Returns an instance without duplicate key/value pair.
- withoutEmptyPairs() : self
- Returns an instance without empty key/value where the value is the null value.
- withoutNumericIndices() : self
- Returns an instance where numeric indices associated to PHP's array like key are removed.
- withoutPair() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- withoutParameters() : self
- Returns an instance without the specified params.
- withPair() : self
- Returns an instance with a new key/value pair added to it.
- withSeparator() : self
- Returns an instance with a different separator.
Methods
__toString()
Returns the instance string representation.
public
__toString() : string
If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.
If the instance is not defined, an empty string is returned
Return values
stringappend()
Returns an instance with the new pairs appended to it.
public
append(Stringable|string $query) : self
This method MUST retain the state of the current instance, and return an instance that contains the modified query
If the pair already exists the value will be added to it.
Parameters
- $query : Stringable|string
Return values
selfappendTo()
Returns a new instance with a specified key/value pair appended as a new pair.
public
appendTo(string $key, Stringable|string|int|bool|null $value) : self
This method MUST retain the state of the current instance, and return an instance that contains the modified query
Parameters
- $key : string
- $value : Stringable|string|int|bool|null
Return values
selfcount()
Returns the number of key/value pairs present in the object.
public
count() : int
Return values
intget()
Returns the first value associated to the given pair name.
public
get(string $key) : string|null
If no value is found null is returned
Parameters
- $key : string
Tags
Return values
string|nullgetAll()
Returns all the values associated to the given pair name as an array or all the instance pairs.
public
getAll(string $key) : array<int, string|null>
If no value is found an empty array is returned
Parameters
- $key : string
Tags
Return values
array<int, string|null>getIterator()
Returns an iterator allowing to go through all key/value pairs contained in this object.
public
getIterator() : Iterator<int, array{0: string, 1: string|null}>
The pair is represented as an array where the first value is the pair key and the second value the pair value.
The key of each pair is a string The value of each pair is a scalar or the null value
Return values
Iterator<int, array{0: string, 1: string|null}>getSeparator()
Returns the query separator.
public
getSeparator() : non-empty-string
Return values
non-empty-stringgetUriComponent()
Returns the instance string representation with its optional URI delimiters.
public
getUriComponent() : string
The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.
If the instance is not defined, an empty string is returned
Return values
stringhas()
Tells whether a list of pair with a specific key exists.
public
has(string ...$keys) : bool
Parameters
- $keys : string
Tags
Return values
boolhasParameter()
Tells whether a list of variable with specific names exists.
public
hasParameter(string ...$names) : bool
Parameters
- $names : string
Tags
Return values
booljsonSerialize()
Returns the instance json representation.
public
jsonSerialize() : string|null
If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986 or RFC 1738.
If the instance is not defined, null is returned
Return values
string|nullmerge()
Returns an instance with the new pairs set to it.
public
merge(Stringable|string $query) : self
This method MUST retain the state of the current instance, and return an instance that contains the modified query
Parameters
- $query : Stringable|string
Tags
Return values
selfpairs()
Returns an iterator allowing to go through all key/value pairs contained in this object.
public
pairs() : iterable<string, string|null>
The return type is as an Iterator where its offset is the pair key and its value the pair value.
The key of each pair is a string The value of each pair is a scalar or the null value
Return values
iterable<string, string|null>parameter()
Returns the value attached to the specific key.
public
parameter(string $name) : mixed
The result is similar to PHP parse_str with the difference that variable names are not mangled.
If a key is submitted it will return the value attached to it or null
Parameters
- $name : string
Tags
Return values
mixed —the collection of stored PHP variables or the empty array if no input is given, the single value of a stored PHP variable or null if the variable is not present in the collection
parameters()
Returns the store PHP variables as elements of an array.
public
parameters() : array<string|int, mixed>
The result is similar as PHP parse_str when used with its second argument with the difference that variable names are not mangled.
Tags
Return values
array<string|int, mixed> —the collection of stored PHP variables or the empty array if no input is given,
sort()
Sorts the query string by offset, maintaining offset to data correlations.
public
sort() : self
This method MUST retain the state of the current instance, and return an instance that contains the modified query
Tags
Return values
selftoRFC1738()
Returns the RFC1738 encoded query.
public
toRFC1738() : string|null
Return values
string|nulltoString()
Returns the instance string representation.
public
toString() : string
If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.
If the instance is not defined, an empty string is returned
Return values
stringvalue()
Returns the instance string representation.
public
value() : string|null
If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.
If the instance is not defined null is returned
Return values
string|nullwithoutDuplicates()
Returns an instance without duplicate key/value pair.
public
withoutDuplicates() : self
This method MUST retain the state of the current instance, and return an instance that contains the query component normalized by removing duplicate pairs whose key/value are the same.
Return values
selfwithoutEmptyPairs()
Returns an instance without empty key/value where the value is the null value.
public
withoutEmptyPairs() : self
This method MUST retain the state of the current instance, and return an instance that contains the query component normalized by removing empty pairs.
A pair is considered empty if its value is equal to the null value
Return values
selfwithoutNumericIndices()
Returns an instance where numeric indices associated to PHP's array like key are removed.
public
withoutNumericIndices() : self
This method MUST retain the state of the current instance, and return an instance that contains the query component normalized so that numeric indexes are removed from the pair key value.
i.e.: toto[3]=bar[3]&foo=bar becomes toto[]=bar[3]&foo=bar
Return values
selfwithoutPair()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
withoutPair(string ...$keys) : self
Since version 7.3.0
use League\Uri\Contracts\QueryInterface::withoutPairByKey() instead
Parameters
- $keys : string
Tags
Return values
selfwithoutParameters()
Returns an instance without the specified params.
public
withoutParameters(string ...$names) : self
This method MUST retain the state of the current instance, and return an instance that contains the modified component without PHP's value. PHP's mangled is not taken into account.
Parameters
- $names : string
Return values
selfwithPair()
Returns an instance with a new key/value pair added to it.
public
withPair(string $key, Stringable|string|int|float|bool|null $value) : self
This method MUST retain the state of the current instance, and return an instance that contains the modified query
If the pair already exists the value will replace the existing value.
Parameters
- $key : string
- $value : Stringable|string|int|float|bool|null
Tags
Return values
selfwithSeparator()
Returns an instance with a different separator.
public
withSeparator(string $separator) : self
This method MUST retain the state of the current instance, and return an instance that contains the query component with a different separator
Parameters
- $separator : string