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 a native PHP array containing all of the elements in this array 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
If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value
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 28
void
clear()
Remove all the elements from this array object
in ArrayInterface at line 34
toArray()
Returns a native PHP array containing all of the elements in this array object
in ArrayInterface at line 41
bool
isEmpty()
Returns true
if this array object contains no elements
at line 32
bool
containsKey(mixed $key)
Returns true
if this map contains a mapping for the specified key
at line 42
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 52
mixed|null
get($key, $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 64
mixed
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 75
mixed
putIfAbsent(mixed $key, mixed $value)
If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value
at line 83
mixed
remove(mixed $key)
Removes the mapping for a key from this map if it is present
at line 95
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 105
mixed
replace(mixed $key, mixed $value)
Replaces the entry for the specified key only if it is currently mapped to some value
at line 118
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.