ServerDataCollection

A DataCollection for "$_SERVER" like data

Look familiar?

Inspired by @fabpot's Symfony 2's HttpFoundation

link https://github.com/symfony/HttpFoundation/blob/master/ServerBag.php
uses \Klein\DataCollection\DataCollection
package Klein\DataCollection

 Methods

Constructor

__construct(array $attributes) 
Inherited
access public
inherited_from \Klein\DataCollection\DataCollection::__construct()

Parameters

$attributes

array

The data attributes of this collection

Magic "__get" method

__get(string $key) : mixed
Inherited

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

see \Klein\DataCollection\get()
access public
inherited_from \Klein\DataCollection\DataCollection::__get()

Parameters

$key

string

The name of the parameter to return

Returns

mixed

Magic "__isset" method

__isset(string $key) : boolean
Inherited

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

see \Klein\DataCollection\exists()
access public
inherited_from \Klein\DataCollection\DataCollection::__isset()

Parameters

$key

string

The name of the parameter

Returns

boolean

Magic "__set" method

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

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

see \Klein\DataCollection\set()
access public
inherited_from \Klein\DataCollection\DataCollection::__set()

Parameters

$key

string

The name of the parameter to set

$value

mixed

The value of the parameter to set

Magic "__unset" method

__unset(string $key) : void
Inherited

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

see \Klein\DataCollection\remove()
access public
inherited_from \Klein\DataCollection\DataCollection::__unset()

Parameters

$key

string

The name of the parameter

Returns all of the attributes in the collection

all(array $mask, boolean $fill_with_nulls) : array
Inherited

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

access public
inherited_from \Klein\DataCollection\DataCollection::all()

Parameters

$mask

array

The parameter mask array

$fill_with_nulls

boolean

Whether or not to fill the returned array with null values to match the given mask

Returns

array

Count the attributes via a simple "count" call

count() : int
Inherited

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

see \Countable::count()
access public
inherited_from \Klein\DataCollection\DataCollection::count()

Returns

int

See if an attribute exists in the collection

exists(string $key) : boolean
Inherited
access public
inherited_from \Klein\DataCollection\DataCollection::exists()

Parameters

$key

string

The name of the parameter

Returns

boolean

Return an attribute of the collection

get(string $key, mixed $default_val) : mixed
Inherited

Return a default value if the key doesn't exist

access public
inherited_from \Klein\DataCollection\DataCollection::get()

Parameters

$key

string

The name of the parameter to return

$default_val

mixed

The default value of the parameter if it contains no value

Returns

mixed

Get our headers from our server data collection

getHeaders() : array

PHP is weird... it puts all of the HTTP request headers in the $_SERVER array. This handles that

access public

Returns

array

Get the aggregate iterator

getIterator() : \ArrayIterator
Inherited

IteratorAggregate interface required method

see \IteratorAggregate::getIterator()
access public
inherited_from \Klein\DataCollection\DataCollection::getIterator()

Returns

Quickly check if a string has a passed prefix

hasPrefix(string $string, string $prefix) : boolean
Static
static
access public

Parameters

$string

string

The string to check

$prefix

string

The prefix to test

Returns

boolean

Merge attributes with the collection's attributes

merge(array $attributes, boolean $hard) : \Klein\DataCollection\DataCollection
Inherited

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

access public
inherited_from \Klein\DataCollection\DataCollection::merge()

Parameters

$attributes

array

The attributes to merge into the collection

$hard

boolean

Whether or not to make the merge "hard"

Returns

Check existence an attribute via array syntax

offsetExists(string $key) : boolean
Inherited

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

see \ArrayAccess::offsetExists()
see \Klein\DataCollection\exists()
access public
inherited_from \Klein\DataCollection\DataCollection::offsetExists()

Parameters

$key

string

The name of the parameter

Returns

boolean

Get an attribute via array syntax

offsetGet(string $key) : mixed
Inherited

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

see \ArrayAccess::offsetGet()
see \Klein\DataCollection\get()
access public
inherited_from \Klein\DataCollection\DataCollection::offsetGet()

Parameters

$key

string

The name of the parameter to return

Returns

mixed

Set an attribute via array syntax

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

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

see \ArrayAccess::offsetSet()
see \Klein\DataCollection\set()
access public
inherited_from \Klein\DataCollection\DataCollection::offsetSet()

Parameters

$key

string

The name of the parameter to set

$value

mixed

The value of the parameter to set

Remove an attribute via array syntax

offsetUnset(string $key) : void
Inherited

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

see \ArrayAccess::offsetUnset()
see \Klein\DataCollection\remove()
access public
inherited_from \Klein\DataCollection\DataCollection::offsetUnset()

Parameters

$key

string

The name of the parameter

Remove an attribute from the collection

remove(string $key) : void
Inherited
access public
inherited_from \Klein\DataCollection\DataCollection::remove()

Parameters

$key

string

The name of the parameter

Replace the collection's attributes

replace(array $attributes) : \Klein\DataCollection\DataCollection
Inherited
access public
inherited_from \Klein\DataCollection\DataCollection::replace()

Parameters

$attributes

array

The attributes to replace the collection's with

Returns

Set an attribute of the collection

set(string $key, mixed $value) : \Klein\DataCollection\DataCollection
Inherited
access public
inherited_from \Klein\DataCollection\DataCollection::set()

Parameters

$key

string

The name of the parameter to set

$value

mixed

The value of the parameter to set

Returns

 Properties

 

$attributes : array
Inherited
access protected
inherited_from \Klein\DataCollection\DataCollection::$$attributes
 

$http_header_prefix : string
static
access protected
 

$http_nonprefixed_headers : string

..

static
access protected