Documentation

QueryInterface extends Countable, IteratorAggregate, UriComponentInterface
in

Tags
extends

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
string

append()

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
self

appendTo()

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
self

count()

Returns the number of key/value pairs present in the object.

public count() : int
Return values
int

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-string

getUriComponent()

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
string

jsonSerialize()

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|null

merge()

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
see
::withPair
Return values
self

pairs()

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
see
http://php.net/parse_str
see
https://wiki.php.net/rfc/on_demand_name_mangling
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
see
http://php.net/parse_str
see
https://wiki.php.net/rfc/on_demand_name_mangling
Return values
array<string|int, mixed>

the collection of stored PHP variables or the empty array if no input is given,

toRFC1738()

Returns the RFC1738 encoded query.

public toRFC1738() : string|null
Return values
string|null

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
string

value()

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|null

withoutDuplicates()

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
self

withoutEmptyPairs()

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
self

withoutNumericIndices()

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
self

withoutPair()

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
codeCoverageIgnore
see
QueryInterface::withoutPairByKey()

Returns an instance without the specified keys.

This method MUST retain the state of the current instance, and return an instance that contains the modified component

Return values
self

withoutParameters()

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
self

withPair()

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
see
https://url.spec.whatwg.org/#dom-urlsearchparams-set
Return values
self

withSeparator()

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
Return values
self

        
On this page

Search results