W3cubDocs

/Symfony 3.0

Symfony\Component\HttpFoundation\ParameterBag

class ParameterBag implements IteratorAggregate, Countable

ParameterBag is a container for key/value pairs.

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 $key, mixed $default = null)

Returns a parameter by name.

set(string $key, mixed $value)

Sets a parameter by name.

bool has(string $key)

Returns true if the parameter is defined.

remove(string $key)

Removes a parameter.

string getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

string getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

string getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

int getInt(string $key, int $default)

Returns the parameter value converted to integer.

bool getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

mixed filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

ArrayIterator getIterator()

Returns an iterator for parameters.

int count()

Returns the number of parameters.

Details

public __construct(array $parameters = array())

Constructor.

Parameters

array $parameters An array of parameters

public array all()

Returns the parameters.

Return Value

array An array of parameters

public array keys()

Returns the parameter keys.

Return Value

array An array of parameter keys

public replace(array $parameters = array())

Replaces the current parameters by a new set.

Parameters

array $parameters An array of parameters

public add(array $parameters = array())

Adds parameters.

Parameters

array $parameters An array of parameters

public mixed get(string $key, mixed $default = null)

Returns a parameter by name.

Parameters

string $key The key
mixed $default The default value if the parameter key does not exist

Return Value

mixed

Exceptions

InvalidArgumentException

public set(string $key, mixed $value)

Sets a parameter by name.

Parameters

string $key The key
mixed $value The value

public bool has(string $key)

Returns true if the parameter is defined.

Parameters

string $key The key

Return Value

bool true if the parameter exists, false otherwise

public remove(string $key)

Removes a parameter.

Parameters

string $key The key

public string getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

public string getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

public string getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

public int getInt(string $key, int $default)

Returns the parameter value converted to integer.

Parameters

string $key The parameter key
int $default The default value if the parameter key does not exist

Return Value

int The filtered value

public bool getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist

Return Value

bool The filtered value

public mixed filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

Parameters

string $key Key.
mixed $default Default = null.
int $filter FILTER_* constant.
mixed $options Filter options.

Return Value

mixed

See also

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

public ArrayIterator getIterator()

Returns an iterator for parameters.

Return Value

ArrayIterator An \ArrayIterator instance

public int count()

Returns the number of parameters.

Return Value

int The number of parameters

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/HttpFoundation/ParameterBag.html