\app\framework\Component\Route\Klein\DataCollectionDataCollection

DataCollection

A generic collection class to contain array-like data, specifically designed to work with HTTP data (request params, session data, etc)

Inspired by @fabpot's Symfony 2's HttpFoundation

Summary

Methods
Properties
Constants
__construct()
keys()
all()
get()
set()
replace()
merge()
exists()
remove()
clear()
isEmpty()
cloneEmpty()
__get()
__set()
__isset()
__unset()
getIterator()
offsetGet()
offsetSet()
offsetExists()
offsetUnset()
count()
No public properties found
No constants found
No protected methods found
$attributes
N/A
No private methods found
No private properties found
N/A

Properties

$attributes

$attributes : 

Collection of data attributes

Type

Methods

__construct()

__construct(array  $attributes = array()) 

Constructor

Parameters

array $attributes

The data attributes of this collection

keys()

keys(array  $mask = null, boolean  $fill_with_nulls = true) : array

Returns all of the key names in the collection

If an optional mask array is passed, this only returns the keys that match the mask

Parameters

array $mask

The parameter mask array

boolean $fill_with_nulls

Whether or not to fill the returned array with values to match the given mask, even if they don't exist in the collection

Returns

array

all()

all(array  $mask = null, boolean  $fill_with_nulls = true) : array

Returns all of the attributes in the collection

If an optional mask array is passed, this only returns the keys that match the mask

Parameters

array $mask

The parameter mask array

boolean $fill_with_nulls

Whether or not to fill the returned array with values to match the given mask, even if they don't exist in the collection

Returns

array

get()

get(string  $key, mixed  $default_val = null) : mixed

Return an attribute of the collection

Return a default value if the key doesn't exist

Parameters

string $key

The name of the parameter to return

mixed $default_val

The default value of the parameter if it contains no value

Returns

mixed

merge()

merge(array  $attributes = array(), boolean  $hard = false) : \app\framework\Component\Route\Klein\DataCollection\DataCollection

Merge attributes with the collection's attributes

Optionally allows a second boolean parameter to merge the attributes into the collection in a "hard" manner, using the "array_replace" method instead of the usual "array_merge" method

Parameters

array $attributes

The attributes to merge into the collection

boolean $hard

Whether or not to make the merge "hard"

Returns

\app\framework\Component\Route\Klein\DataCollection\DataCollection

exists()

exists(string  $key) : boolean

See if an attribute exists in the collection

Parameters

string $key

The name of the parameter

Returns

boolean

remove()

remove(string  $key) : void

Remove an attribute from the collection

Parameters

string $key

The name of the parameter

isEmpty()

isEmpty() : boolean

Check if the collection is empty

Returns

boolean

__get()

__get(string  $key) : mixed

Magic "__get" method

Allows the ability to arbitrarily request an attribute from this instance while treating it as an instance property

Parameters

string $key

The name of the parameter to return

Returns

mixed

__set()

__set(string  $key, mixed  $value) : void

Magic "__set" method

Allows the ability to arbitrarily set an attribute from this instance while treating it as an instance property

Parameters

string $key

The name of the parameter to set

mixed $value

The value of the parameter to set

__isset()

__isset(string  $key) : boolean

Magic "__isset" method

Allows the ability to arbitrarily check the existence of an attribute from this instance while treating it as an instance property

Parameters

string $key

The name of the parameter

Returns

boolean

__unset()

__unset(string  $key) : void

Magic "__unset" method

Allows the ability to arbitrarily remove an attribute from this instance while treating it as an instance property

Parameters

string $key

The name of the parameter

getIterator()

getIterator() : \ArrayIterator

Get the aggregate iterator

IteratorAggregate interface required method

Returns

\ArrayIterator

offsetGet()

offsetGet(string  $key) : mixed

Get an attribute via array syntax

Allows the access of attributes of this instance while treating it like an array

Parameters

string $key

The name of the parameter to return

Returns

mixed

offsetSet()

offsetSet(string  $key, mixed  $value) : void

Set an attribute via array syntax

Allows the access of attributes of this instance while treating it like an array

Parameters

string $key

The name of the parameter to set

mixed $value

The value of the parameter to set

offsetExists()

offsetExists(string  $key) : boolean

Check existence an attribute via array syntax

Allows the access of attributes of this instance while treating it like an array

Parameters

string $key

The name of the parameter

Returns

boolean

offsetUnset()

offsetUnset(string  $key) : void

Remove an attribute via array syntax

Allows the access of attributes of this instance while treating it like an array

Parameters

string $key

The name of the parameter

count()

count() : integer

Count the attributes via a simple "count" call

Allows the use of the "count" function (or any internal counters) to simply count the number of attributes in the collection.

Returns

integer