Open Monograph Press
3.3.0
|
Public Member Functions | |
__construct (array $data=array()) | |
add ($key, $value) | |
clear () | |
count () | |
filter (\Closure $closure, $static=true) | |
get ($key) | |
getAll (array $keys=null) | |
getIterator () | |
getKeys () | |
getPath ($path, $separator='/', $data=null) | |
hasKey ($key) | |
hasValue ($value) | |
inject ($input) | |
keySearch ($key) | |
map (\Closure $closure, array $context=array(), $static=true) | |
merge ($data) | |
offsetExists ($offset) | |
offsetGet ($offset) | |
offsetSet ($offset, $value) | |
offsetUnset ($offset) | |
overwriteWith ($data) | |
remove ($key) | |
replace (array $data) | |
set ($key, $value) | |
setPath ($path, $value) | |
toArray () | |
Static Public Member Functions | |
static | fromConfig (array $config=array(), array $defaults=array(), array $required=array()) |
Protected Attributes | |
$data | |
Key value pair collection object
Definition at line 11 of file Collection.php.
Guzzle\Common\Collection::__construct | ( | array | $data = array() | ) |
array | $data | Associative array of data to set |
Definition at line 22 of file Collection.php.
References Guzzle\Common\Collection\$data.
Guzzle\Common\Collection::add | ( | $key, | |
$value | |||
) |
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.
string | $key | Key to add |
mixed | $value | Value to add to the key |
Definition at line 123 of file Collection.php.
Referenced by Guzzle\Common\Collection\merge().
Guzzle\Common\Collection::clear | ( | ) |
Guzzle\Common\Collection::count | ( | ) |
Definition at line 48 of file Collection.php.
Guzzle\Common\Collection::filter | ( | \Closure | $closure, |
$static = true |
|||
) |
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.
\Closure | $closure | Closure evaluation function |
bool | $static | Set to TRUE to use the same class as the return rather than returning a Collection |
Definition at line 285 of file Collection.php.
|
static |
Create a new collection from an array, validate the keys, and add default values where missing
array | $config | Configuration values to apply. |
array | $defaults | Default parameters |
array | $required | Required parameter names |
InvalidArgumentException | if a parameter is missing |
Definition at line 37 of file Collection.php.
References Guzzle\Common\Collection\$data.
Referenced by Guzzle\Plugin\Oauth\OauthPlugin\__construct(), Guzzle\Tests\Service\Mock\MockClient\factory(), and Guzzle\Tests\Common\CollectionTest\testPreparesFromConfig().
Guzzle\Common\Collection::get | ( | $key | ) |
Get a specific key value.
string | $key | Key to retrieve. |
Definition at line 94 of file Collection.php.
Guzzle\Common\Collection::getAll | ( | array | $keys = null | ) |
Get all or a subset of matching key value pairs
array | $keys | Pass an array of keys to retrieve only a subset of key value pairs |
Definition at line 82 of file Collection.php.
References Guzzle\Common\Collection\$data.
Guzzle\Common\Collection::getIterator | ( | ) |
Definition at line 53 of file Collection.php.
Guzzle\Common\Collection::getKeys | ( | ) |
Guzzle\Common\Collection::getPath | ( | $path, | |
$separator = '/' , |
|||
$data = 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.
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) |
Definition at line 357 of file Collection.php.
References Guzzle\Common\Collection\$data.
Referenced by Guzzle\Tests\Common\CollectionTest\testGetPath().
Guzzle\Common\Collection::hasKey | ( | $key | ) |
Returns whether or not the specified key is present.
string | $key | The key for which to check the existence. |
Definition at line 167 of file Collection.php.
Guzzle\Common\Collection::hasValue | ( | $value | ) |
Checks if any keys contains a certain value
string | $value | Value to search for |
Definition at line 197 of file Collection.php.
Guzzle\Common\Collection::inject | ( | $input | ) |
Inject configuration settings into an input string
string | $input | Input to inject |
Definition at line 396 of file Collection.php.
References Guzzle\Common\Version\warn().
Guzzle\Common\Collection::keySearch | ( | $key | ) |
Case insensitive search the keys in the collection
string | $key | Key to search for |
Definition at line 179 of file Collection.php.
Guzzle\Common\Collection::map | ( | \Closure | $closure, |
array | $context = array() , |
||
$static = true |
|||
) |
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
\Closure | $closure | Closure to apply |
array | $context | Context to pass to the closure |
bool | $static | Set to TRUE to use the same class as the return rather than returning a Collection |
Definition at line 265 of file Collection.php.
Referenced by Guzzle\Tests\Service\Resource\ModelTest\testCanBeUsedWithoutStructure().
Guzzle\Common\Collection::merge | ( | $data | ) |
Add and merge in a Collection or array of key value pair data.
Collection | array | $data | Associative array of key value pair data |
Definition at line 223 of file Collection.php.
References Guzzle\Common\Collection\$data, and Guzzle\Common\Collection\add().
Guzzle\Common\Collection::offsetExists | ( | $offset | ) |
Definition at line 297 of file Collection.php.
Guzzle\Common\Collection::offsetGet | ( | $offset | ) |
Definition at line 302 of file Collection.php.
Guzzle\Common\Collection::offsetSet | ( | $offset, | |
$value | |||
) |
Definition at line 307 of file Collection.php.
Guzzle\Common\Collection::offsetUnset | ( | $offset | ) |
Definition at line 312 of file Collection.php.
Guzzle\Common\Collection::overwriteWith | ( | $data | ) |
Over write key value pairs in this collection with all of the data from an array or collection.
array | \Traversable | $data | Values to override over this config |
Definition at line 239 of file Collection.php.
References Guzzle\Common\Collection\$data.
Guzzle\Common\Collection::remove | ( | $key | ) |
Remove a specific key value pair
string | $key | A key to remove |
Definition at line 143 of file Collection.php.
Guzzle\Common\Collection::replace | ( | array | $data | ) |
Replace the data of the object with the value of an array
array | $data | Associative array of data |
Definition at line 209 of file Collection.php.
References Guzzle\Common\Collection\$data.
Guzzle\Common\Collection::set | ( | $key, | |
$value | |||
) |
Set a key value pair
string | $key | Key to set |
mixed | $value | Value to set |
Definition at line 107 of file Collection.php.
Guzzle\Common\Collection::setPath | ( | $path, | |
$value | |||
) |
Set a value into a nested array key. Keys will be created as needed to set the value.
string | $path | Path to set |
mixed | $value | Value to set at the key |
RuntimeException | when trying to setPath using a nested path that travels through a scalar value |
Definition at line 326 of file Collection.php.
References Guzzle\Common\Collection\$data.
Guzzle\Common\Collection::toArray | ( | ) |
Get the array representation of an object
Implements Guzzle\Common\ToArrayInterface.
Definition at line 58 of file Collection.php.
References Guzzle\Common\Collection\$data.
Referenced by Guzzle\Service\Resource\Model\__toString(), and Guzzle\Service\Command\AbstractCommand\validate().
|
protected |
Data associated with the object.
Definition at line 17 of file Collection.php.
Referenced by Guzzle\Common\Collection\__construct(), Guzzle\Service\Resource\Model\__construct(), Guzzle\Common\Collection\fromConfig(), Guzzle\Common\Collection\getAll(), Guzzle\Common\Collection\getPath(), Guzzle\Common\Collection\merge(), Guzzle\Common\Collection\overwriteWith(), Guzzle\Http\QueryString\prepareData(), Guzzle\Common\Collection\replace(), Guzzle\Common\Collection\setPath(), and Guzzle\Common\Collection\toArray().