NamedParameterMap
class NamedParameterMap extends AbstractMap (View source)
NamedParameterMap
represents a mapping of values to a set of named keys
that may optionally be typed
Traits
Properties
protected array | $data | The items of this array. | from AbstractArray |
protected array | $namedParameters | Named parameters defined for this map. |
Methods
Constructs a new NamedParameterMap
.
Returns true
if the given offset exists in this array.
Sets the given value to the given offset in the map.
Removes the given offset and its value from the array.
Returns a serialized string representation of this array object.
Converts a serialized string representation into an instance object.
Returns true
if this map contains a mapping for the specified key.
Returns true
if this map maps one or more keys to the specified value.
Returns the value to which the specified key is mapped, null
if this
map contains no mapping for the key, or (optionally) $defaultValue
if
this map contains no mapping for the key.
Associates the specified value with the specified key in this map.
Associates the specified value with the specified key in this map only if it is not already set.
Removes the mapping for a key from this map if it is present.
Removes the entry for the specified key only if it is currently mapped to the specified value.
Replaces the entry for the specified key only if it is currently mapped to some value.
Replaces the entry for the specified key only if currently mapped to the specified value.
Returns true
if value is of the specified type.
Returns a string representation of the value.
Returns named parameters set for this NamedParameterMap
.
Given an array of named parameters, constructs a proper mapping of named parameters to types.
Details
at line 43
__construct(array $namedParameters, array $data = [])
Constructs a new NamedParameterMap
.
in AbstractArray at line 51
Traversable
getIterator()
Returns an iterator for this array.
in AbstractArray at line 65
bool
offsetExists(mixed $offset)
Returns true
if the given offset exists in this array.
in AbstractArray at line 80
mixed|null
offsetGet(mixed $offset)
Returns the value at the specified offset.
at line 69
void
offsetSet(mixed|null $offset, mixed $value)
Sets the given value to the given offset in the map.
in AbstractArray at line 110
void
offsetUnset(mixed $offset)
Removes the given offset and its value from the array.
in AbstractArray at line 122
string
serialize()
Returns a serialized string representation of this array object.
in AbstractArray at line 134
void
unserialize(string $serialized)
Converts a serialized string representation into an instance object.
in AbstractArray at line 146
int
count()
Returns the number of items in this array.
in AbstractArray at line 154
void
clear()
Removes all items from this array.
in AbstractArray at line 164
array
toArray()
Returns a native PHP array representation of this array object.
in AbstractArray at line 174
bool
isEmpty()
Returns true
if this array is empty.
in AbstractMap at line 53
bool
containsKey(mixed $key)
Returns true
if this map contains a mapping for the specified key.
in AbstractMap at line 67
bool
containsValue(mixed $value)
Returns true
if this map maps one or more keys to the specified value.
This performs a strict type check on the value.
in AbstractMap at line 77
array
keys()
Return an array of the keys contained in this map.
in AbstractMap at line 92
mixed|null
get(mixed $key, mixed $defaultValue = null)
Returns the value to which the specified key is mapped, null
if this
map contains no mapping for the key, or (optionally) $defaultValue
if
this map contains no mapping for the key.
in AbstractMap at line 113
mixed|null
put(mixed $key, mixed $value)
Associates the specified value with the specified key in this map.
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
in AbstractMap at line 134
mixed|null
putIfAbsent(mixed $key, mixed $value)
Associates the specified value with the specified key in this map only if it is not already set.
If there is already a value associated with $key
, this returns that
value without replacing it.
in AbstractMap at line 153
mixed|null
remove(mixed $key)
Removes the mapping for a key from this map if it is present.
in AbstractMap at line 172
bool
removeIf(mixed $key, mixed $value)
Removes the entry for the specified key only if it is currently mapped to the specified value.
This performs a strict type check on the value.
in AbstractMap at line 193
mixed|null
replace(mixed $key, mixed $value)
Replaces the entry for the specified key only if it is currently mapped to some value.
in AbstractMap at line 216
bool
replaceIf(mixed $key, mixed $oldValue, mixed $newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.
This performs a strict type check on the value.
protected bool
checkType(string $type, mixed $value)
Returns true
if value is of the specified type.
in ValueToStringTrait at line 38
protected string
toolValueToString(mixed $value)
Returns a string representation of the value.
- null value:
'NULL'
- boolean:
'TRUE'
,'FALSE'
- array:
'Array'
- scalar: converted-value
- resource:
'(type resource #number)'
- object with
__toString()
: result of__toString()
- object DateTime: ISO 8601 date
- object:
'(className Object)'
- anonymous function: same as object
at line 54
array
getNamedParameters()
Returns named parameters set for this NamedParameterMap
.
at line 97
protected array
filterNamedParameters(array $namedParameters)
Given an array of named parameters, constructs a proper mapping of named parameters to types.