class ServerBag extends ParameterBag

ServerBag is a container for HTTP headers from the $_SERVER variable.

Methods

__construct(array $parameters = array())

Constructor.

array
all()

Returns the parameters.

array
keys()

Returns the parameter keys.

replace(array $parameters = array())

Replaces the current parameters by a new set.

add(array $parameters = array())

Adds parameters.

mixed
get(string $path, mixed $default = null, boolean $deep = false)

Returns a parameter by name.

set(string $key, mixed $value)

Sets a parameter by name.

Boolean
has(string $key)

Returns true if the parameter is defined.

remove(string $key)

Removes a parameter.

string
getAlpha(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters of the parameter value.

string
getAlnum(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters and digits of the parameter value.

string
getDigits(string $key, mixed $default = '', boolean $deep = false)

Returns the digits of the parameter value.

integer
getInt(string $key, mixed $default, boolean $deep = false)

Returns the parameter value converted to integer.

mixed
filter(string $key, mixed $default = null, boolean $deep = false, integer $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

getIterator()

Returns an iterator for parameters.

int
count()

Returns the number of parameters.

array
getHeaders()

Gets the HTTP headers.

Details

in ParameterBag at line line 37
__construct(array $parameters = array())

Constructor.

Parameters

array $parameters An array of parameters

in ParameterBag at line line 49
array all()

Returns the parameters.

Return Value

array An array of parameters

in ParameterBag at line line 61
array keys()

Returns the parameter keys.

Return Value

array An array of parameter keys

in ParameterBag at line line 73
replace(array $parameters = array())

Replaces the current parameters by a new set.

Parameters

array $parameters An array of parameters

in ParameterBag at line line 85
add(array $parameters = array())

Adds parameters.

Parameters

array $parameters An array of parameters

in ParameterBag at line line 103
mixed get(string $path, mixed $default = null, boolean $deep = false)

Returns a parameter by name.

Parameters

string $path The key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

mixed

Exceptions

InvalidArgumentException

in ParameterBag at line line 160
set(string $key, mixed $value)

Sets a parameter by name.

Parameters

string $key The key
mixed $value The value

in ParameterBag at line line 174
Boolean has(string $key)

Returns true if the parameter is defined.

Parameters

string $key The key

Return Value

Boolean true if the parameter exists, false otherwise

in ParameterBag at line line 186
remove(string $key)

Removes a parameter.

Parameters

string $key The key

in ParameterBag at line line 202
string getAlpha(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line line 218
string getAlnum(string $key, mixed $default = '', boolean $deep = false)

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line line 234
string getDigits(string $key, mixed $default = '', boolean $deep = false)

Returns the digits of the parameter value.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

string The filtered value

in ParameterBag at line line 251
integer getInt(string $key, mixed $default, boolean $deep = false)

Returns the parameter value converted to integer.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist
boolean $deep If true, a path like foo[bar] will find deeper items

Return Value

integer The filtered value

in ParameterBag at line line 269
mixed filter(string $key, mixed $default = null, boolean $deep = false, integer $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

Parameters

string $key Key.
mixed $default Default = null.
boolean $deep Default = false.
integer $filter FILTER_* constant.
mixed $options Filter options.

Return Value

mixed

See also

http://php.net/manual/en/function.filter-var.php

in ParameterBag at line line 291
ArrayIterator getIterator()

Returns an iterator for parameters.

Return Value

ArrayIterator An \ArrayIterator instance

in ParameterBag at line line 301
int count()

Returns the number of parameters.

Return Value

int The number of parameters

at line line 28
array getHeaders()

Gets the HTTP headers.

Return Value

array