MapInterface
interface MapInterface implements ArrayInterface (View source)
An object that maps keys to values.
A map cannot contain duplicate keys; each key can map to at most one value.
Methods
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.
Return an array of the keys contained in this map.
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.
Details
in ArrayInterface at line 29
void
clear()
Removes all items from this array.
in ArrayInterface at line 36
array
toArray()
Returns a native PHP array representation of this array object.
in ArrayInterface at line 43
bool
isEmpty()
Returns true
if this array is empty.
at line 33
bool
containsKey(mixed $key)
Returns true
if this map contains a mapping for the specified key.
at line 44
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.
at line 51
array
keys()
Return an array of the keys contained in this map.
at line 63
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.
at line 77
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.
at line 92
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.
at line 102
mixed|null
remove(mixed $key)
Removes the mapping for a key from this map if it is present.
at line 115
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.
at line 127
mixed|null
replace(mixed $key, mixed $value)
Replaces the entry for the specified key only if it is currently mapped to some value.
at line 141
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.