ParamBag
in package
implements
Countable
Lightweight wrapper for request parameters.
This class represents the request parameters. Parameters are stored in an associative array with the parameter name as key. Because e.g. SOLR allows repeated query parameters the values are always stored in an array.
Tags
Interfaces, Classes, Traits and Enums
- Countable
Table of Contents
- $params : array<string|int, mixed>
- Parameters
- __construct() : void
- Constructor.
- add() : void
- Add parameter value.
- contains() : bool
- Return true if the bag contains a parameter-value-pair.
- count() : int
- Count parameters in internal array. Needed for Countable interface.
- exchangeArray() : array<string|int, mixed>
- Exchange the parameter array.
- get() : mixed|null
- Return parameter value.
- getArrayCopy() : array<string|int, mixed>
- Return copy of parameters as array.
- hasParam() : bool
- Return true if the bag contains any value(s) for the specified parameter.
- mergeWith() : void
- Merge with another parameter bag.
- mergeWithAll() : void
- Merge with all supplied parameter bags.
- remove() : void
- Remove a parameter.
- request() : array<string|int, mixed>
- Return array of params ready to be used in a HTTP request.
- set() : void
- Set a parameter.
Properties
$params
Parameters
protected
array<string|int, mixed>
$params
= []
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $initial = [] ]) : void
Parameters
- $initial : array<string|int, mixed> = []
-
Initial parameters
Return values
void —add()
Add parameter value.
public
add(string $name, mixed $value[, bool $deduplicate = true ]) : void
Parameters
- $name : string
-
Parameter name
- $value : mixed
-
Parameter value
- $deduplicate : bool = true
-
Deduplicate parameter values
Return values
void —contains()
Return true if the bag contains a parameter-value-pair.
public
contains(string $name, string $value) : bool
Parameters
- $name : string
-
Parameter name
- $value : string
-
Parameter value
Return values
bool —count()
Count parameters in internal array. Needed for Countable interface.
public
count() : int
Return values
int —exchangeArray()
Exchange the parameter array.
public
exchangeArray(array<string|int, mixed> $input) : array<string|int, mixed>
Parameters
- $input : array<string|int, mixed>
-
New parameters
Return values
array<string|int, mixed> —Old parameters
get()
Return parameter value.
public
get(string $name) : mixed|null
Parameters
- $name : string
-
Parameter name
Return values
mixed|null —Parameter value or NULL if not set
getArrayCopy()
Return copy of parameters as array.
public
getArrayCopy() : array<string|int, mixed>
Return values
array<string|int, mixed> —hasParam()
Return true if the bag contains any value(s) for the specified parameter.
public
hasParam(string $name) : bool
Parameters
- $name : string
-
Parameter name
Return values
bool —mergeWith()
Merge with another parameter bag.
public
mergeWith(ParamBag $bag) : void
Parameters
- $bag : ParamBag
-
Parameter bag to merge with
Return values
void —mergeWithAll()
Merge with all supplied parameter bags.
public
mergeWithAll(array<string|int, mixed> $bags) : void
Parameters
- $bags : array<string|int, mixed>
-
Parameter bags to merge with
Return values
void —remove()
Remove a parameter.
public
remove(string $name) : void
Parameters
- $name : string
-
Parameter name
Return values
void —request()
Return array of params ready to be used in a HTTP request.
public
request() : array<string|int, mixed>
Returns a numerical array with all request parameters as properly URL encoded key-value pairs.
Return values
array<string|int, mixed> —set()
Set a parameter.
public
set(string $name, string $value) : void
Parameters
- $name : string
-
Parameter name
- $value : string
-
Parameter value