Class Guzzle\Http\QueryString

InheritanceGuzzle\Http\QueryString » Guzzle\Common\Collection
ImplementsArrayAccess, Countable, Guzzle\Common\ToArrayInterface, IteratorAggregate

Query string object to handle managing query string parameters and aggregating those parameters together as a string.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$aggregator Guzzle\Http\QueryAggregator\QueryAggregatorInterface Guzzle\Http\QueryString
$data array Data associated with the object. Guzzle\Common\Collection
$fieldSeparator string The query string field separator (e.g. '&') Guzzle\Http\QueryString
$urlEncode bool URL encode fields and values Guzzle\Http\QueryString
$valueSeparator string The query string value separator (e.g. '=') Guzzle\Http\QueryString

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Guzzle\Common\Collection
__toString() Convert the query string parameters to a query string string Guzzle\Http\QueryString
add() Add a value to a key. If a key of the same name has already been added, the key value will be converted into an array and the new value will be pushed to the end of the array. Guzzle\Common\Collection
clear() Removes all key value pairs Guzzle\Common\Collection
count() Guzzle\Common\Collection
encodeValue() URL encodes a value based on the url encoding type of the query string object Guzzle\Http\QueryString
filter() Iterates over each key value pair in the collection passing them to the Closure. If the Closure function returns true, the current value from input is returned into the result Collection. The Closure must accept three parameters: (string) $key, (string) $value and return Boolean TRUE or FALSE for each value. Guzzle\Common\Collection
fromConfig() Create a new collection from an array, validate the keys, and add default values where missing Guzzle\Common\Collection
fromString() Parse a query string into a QueryString object Guzzle\Http\QueryString
get() Get a specific key value. Guzzle\Common\Collection
getAll() Get all or a subset of matching key value pairs Guzzle\Common\Collection
getFieldSeparator() Get the query string field separator Guzzle\Http\QueryString
getIterator() Guzzle\Common\Collection
getKeys() Get all keys in the collection Guzzle\Common\Collection
getPath() Gets a value from the collection using an array path (e.g. foo/baz/bar would retrieve bar from two nested arrays) Allows for wildcard searches which recursively combine matches up to the level at which the wildcard occurs. This can be useful for accepting any key of a sub-array and combining matching keys from each diverging path. Guzzle\Common\Collection
getUrlEncoding() Returns the type of URL encoding used by the query string Guzzle\Http\QueryString
getValueSeparator() Get the query string value separator Guzzle\Http\QueryString
hasKey() Returns whether or not the specified key is present. Guzzle\Common\Collection
hasValue() Checks if any keys contains a certain value Guzzle\Common\Collection
inject() Inject configuration settings into an input string Guzzle\Common\Collection
isUrlEncoding() Returns true or false if using URL encoding Guzzle\Http\QueryString
keySearch() Case insensitive search the keys in the collection Guzzle\Common\Collection
map() Returns a Collection containing all the elements of the collection after applying the callback function to each one. The Closure should accept three parameters: (string) $key, (string) $value, (array) $context and return a modified value Guzzle\Common\Collection
merge() Add and merge in a Collection or array of key value pair data. Guzzle\Common\Collection
offsetExists() Guzzle\Common\Collection
offsetGet() Guzzle\Common\Collection
offsetSet() Guzzle\Common\Collection
offsetUnset() Guzzle\Common\Collection
overwriteWith() Over write key value pairs in this collection with all of the data from an array or collection. Guzzle\Common\Collection
remove() Remove a specific key value pair Guzzle\Common\Collection
replace() Replace the data of the object with the value of an array Guzzle\Common\Collection
set() Set a key value pair Guzzle\Common\Collection
setAggregator() Provide a function for combining multi-valued query string parameters into a single or multiple fields Guzzle\Http\QueryString
setFieldSeparator() Set the query string separator Guzzle\Http\QueryString
setPath() Set a value into a nested array key. Keys will be created as needed to set the value. Guzzle\Common\Collection
setValueSeparator() Set the query string value separator Guzzle\Http\QueryString
toArray() Guzzle\Common\Collection
urlEncode() Returns an array of url encoded field names and values Guzzle\Http\QueryString
useUrlEncoding() Set whether or not field names and values should be rawurlencoded Guzzle\Http\QueryString

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
prepareData() Url encode parameter data and convert nested query strings into a flattened hash. Guzzle\Http\QueryString

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
BLANK "_guzzle_blank_" Guzzle\Http\QueryString
FORM_URLENCODED 'application/x-www-form-urlencoded' Guzzle\Http\QueryString
RFC_3986 'RFC 3986' Guzzle\Http\QueryString

Property Details

$aggregator protected property
$fieldSeparator protected property

The query string field separator (e.g. '&')

protected string $fieldSeparator '&'
$urlEncode protected property

URL encode fields and values

protected bool $urlEncode 'RFC 3986'
$valueSeparator protected property

The query string value separator (e.g. '=')

protected string $valueSeparator '='

Method Details

__toString() public method

Convert the query string parameters to a query string string

public string __toString ( )
throws Guzzle\Common\Exception\RuntimeException
encodeValue() public method

URL encodes a value based on the url encoding type of the query string object

public string encodeValue ( $value )
$value string

Value to encode

fromString() public static method

Parse a query string into a QueryString object

public static self fromString ( $query )
$query string

Query string to parse

getFieldSeparator() public method

Get the query string field separator

public string getFieldSeparator ( )
getUrlEncoding() public method

Returns the type of URL encoding used by the query string

One of: false, "RFC 3986", or "application/x-www-form-urlencoded"

public bool|string getUrlEncoding ( )
getValueSeparator() public method

Get the query string value separator

public string getValueSeparator ( )
isUrlEncoding() public method

Returns true or false if using URL encoding

public bool isUrlEncoding ( )
prepareData() protected method

Url encode parameter data and convert nested query strings into a flattened hash.

protected array prepareData ( array $data )
$data array

The data to encode

return array

Returns an array of encoded values and keys

setAggregator() public method

Provide a function for combining multi-valued query string parameters into a single or multiple fields

See also Guzzle\Http\QueryString::aggregateUsingComma().

public self setAggregator ( Guzzle\Http\QueryAggregator\QueryAggregatorInterface $aggregator null )
$aggregator null|Guzzle\Http\QueryAggregator\QueryAggregatorInterface

Pass in a QueryAggregatorInterface object to handle converting

                                             deeply nested query string variables into a flattened array.
                                             Pass null to use the default PHP style aggregator. For legacy
                                             reasons, this function accepts a callable that must accepts a
                                             $key, $value, and query object.
setFieldSeparator() public method

Set the query string separator

public self setFieldSeparator ( $separator )
$separator string

The query string separator that will separate fields

setValueSeparator() public method

Set the query string value separator

public self setValueSeparator ( $separator )
$separator string

The query string separator that will separate values from fields

urlEncode() public method

Returns an array of url encoded field names and values

public array urlEncode ( )
useUrlEncoding() public method

Set whether or not field names and values should be rawurlencoded

public self useUrlEncoding ( $encode )
$encode bool|string

Set to TRUE to use RFC 3986 encoding (rawurlencode), false to disable encoding, or

                       form_urlencoding to use application/x-www-form-urlencoded encoding (urlencode)