Constants

RFC_3986

RFC_3986 = 'RFC 3986' : string

FORM_URLENCODED

FORM_URLENCODED = 'application/x-www-form-urlencoded' : string

BLANK

BLANK = "_guzzle_blank_" : string

Properties

$data

$data : array

Type

array — Data associated with the object.

$fieldSeparator

$fieldSeparator : string

Type

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

$valueSeparator

$valueSeparator : string

Type

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

$urlEncode

$urlEncode : boolean

Type

boolean — URL encode fields and values

$defaultAggregator

$defaultAggregator : array

Type

array — Cached PHP aggregator

Methods

__construct()

__construct(array  $data = array()) 

Parameters

array $data

Associative array of data to set

fromConfig()

fromConfig(array  $config = array(), array  $defaults = array(), array  $required = array()) : self

Create a new collection from an array, validate the keys, and add default values where missing

Parameters

array $config

Configuration values to apply.

array $defaults

Default parameters

array $required

Required parameter names

Throws

\Guzzle\Common\Exception\InvalidArgumentException

if a parameter is missing

Returns

self

count()

count() 

getIterator()

getIterator() 

toArray()

toArray() : array

Get the array representation of an object

Returns

array

getAll()

getAll(array  $keys = null) : array

Get all or a subset of matching key value pairs

Parameters

array $keys

Pass an array of keys to retrieve only a subset of key value pairs

Returns

array —

Returns an array of all matching key value pairs

get()

get(string  $key) : mixed|null

Get a specific key value.

Parameters

string $key

Key to retrieve.

Returns

mixed|null —

Value of the key or NULL

set()

set(string  $key, mixed  $value) : \Guzzle\Common\Collection

Set a key value pair

Parameters

string $key

Key to set

mixed $value

Value to set

Returns

\Guzzle\Common\Collection

Returns a reference to the object

add()

add(string  $key, mixed  $value) : \Guzzle\Common\Collection

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.

Parameters

string $key

Key to add

mixed $value

Value to add to the key

Returns

\Guzzle\Common\Collection

Returns a reference to the object.

remove()

remove(string  $key) : \Guzzle\Common\Collection

Remove a specific key value pair

Parameters

string $key

A key to remove

Returns

\Guzzle\Common\Collection

getKeys()

getKeys() : array

Get all keys in the collection

Returns

array

hasKey()

hasKey(string  $key) : boolean

Returns whether or not the specified key is present.

Parameters

string $key

The key for which to check the existence.

Returns

boolean

keySearch()

keySearch(string  $key) : boolean|string

Case insensitive search the keys in the collection

Parameters

string $key

Key to search for

Returns

boolean|string —

Returns false if not found, otherwise returns the key

hasValue()

hasValue(string  $value) : mixed

Checks if any keys contains a certain value

Parameters

string $value

Value to search for

Returns

mixed —

Returns the key if the value was found FALSE if the value was not found.

replace()

replace(array  $data) : \Guzzle\Common\Collection

Replace the data of the object with the value of an array

Parameters

array $data

Associative array of data

Returns

\Guzzle\Common\Collection

Returns a reference to the object

merge()

merge(\Guzzle\Common\Collection|array  $data) : \Guzzle\Common\Collection

Add and merge in a Collection or array of key value pair data.

Parameters

\Guzzle\Common\Collection|array $data

Associative array of key value pair data

Returns

\Guzzle\Common\Collection

Returns a reference to the object.

overwriteWith()

overwriteWith(array|\Traversable  $data) : self

Over write key value pairs in this collection with all of the data from an array or collection.

Parameters

array|\Traversable $data

Values to override over this config

Returns

self

map()

map(\Closure  $closure, array  $context = array(), boolean  $static = true) : \Guzzle\Common\Collection

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

Parameters

\Closure $closure

Closure to apply

array $context

Context to pass to the closure

boolean $static

Set to TRUE to use the same class as the return rather than returning a Collection

Returns

\Guzzle\Common\Collection

filter()

filter(\Closure  $closure, boolean  $static = true) : \Guzzle\Common\Collection

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.

Parameters

\Closure $closure

Closure evaluation function

boolean $static

Set to TRUE to use the same class as the return rather than returning a Collection

Returns

\Guzzle\Common\Collection

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetGet()

offsetGet(  $offset) 

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

setPath()

setPath(string  $path, mixed  $value) : self

Set a value into a nested array key. Keys will be created as needed to set the value.

Parameters

string $path

Path to set

mixed $value

Value to set at the key

Throws

\Guzzle\Common\Exception\RuntimeException

when trying to setPath using a nested path that travels through a scalar value

Returns

self

getPath()

getPath(string  $path, string  $separator = '/', mixed  $data = null) : mixed|null

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.

Parameters

string $path

Path to traverse and retrieve a value from

string $separator

Character used to add depth to the search

mixed $data

Optional data to descend into (used when wildcards are encountered)

Returns

mixed|null

inject()

inject(string  $input) : string

Inject configuration settings into an input string

Parameters

string $input

Input to inject

Returns

string

fromString()

fromString(string  $query) : self

Parse a query string into a QueryString object

Parameters

string $query

Query string to parse

Returns

self

__toString()

__toString() : string

Convert the query string parameters to a query string string

Throws

\Guzzle\Common\Exception\RuntimeException

Returns

string

getFieldSeparator()

getFieldSeparator() : string

Get the query string field separator

Returns

string

getValueSeparator()

getValueSeparator() : string

Get the query string value separator

Returns

string

getUrlEncoding()

getUrlEncoding() : boolean|string

Returns the type of URL encoding used by the query string

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

Returns

boolean|string

isUrlEncoding()

isUrlEncoding() : boolean

Returns true or false if using URL encoding

Returns

boolean

setAggregator()

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

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

Parameters

null|\Guzzle\Http\QueryAggregator\QueryAggregatorInterface $aggregator

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.

Returns

self

useUrlEncoding()

useUrlEncoding(boolean|string  $encode) : self

Set whether or not field names and values should be rawurlencoded

Parameters

boolean|string $encode

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)

Returns

self

setFieldSeparator()

setFieldSeparator(string  $separator) : self

Set the query string separator

Parameters

string $separator

The query string separator that will separate fields

Returns

self

setValueSeparator()

setValueSeparator(string  $separator) : self

Set the query string value separator

Parameters

string $separator

The query string separator that will separate values from fields

Returns

self

urlEncode()

urlEncode() : array

Returns an array of url encoded field names and values

Returns

array

encodeValue()

encodeValue(string  $value) : string

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

Parameters

string $value

Value to encode

Returns

string

prepareData()

prepareData(array  $data) : array

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

Parameters

array $data

The data to encode

Returns

array —

Returns an array of encoded values and keys

convertKvp()

convertKvp(string  $name, mixed  $value) : string

Converts a key value pair that can contain strings, nulls, false, or arrays into a single string.

Parameters

string $name

Name of the field

mixed $value

Value of the field

Returns

string