AbstractMap
abstract class AbstractMap extends AbstractArray implements MapInterface (View source)
This class provides an implementation of the MapInterface, to minimize the effort required to implement this interface
Properties
protected array | $data | from AbstractArray |
Methods
Checks whether the specified offset exists in the array
Returns the value stored at the specified offset in the array
Sets the specified offset in the map with the given value
Removes the specified offset and its value from the map
Converts this map object to a string when the object is serialized
with serialize()
Re-constructs the object from its serialized form
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 AbstractArray at line 33
__construct(array $data = [])
Constructs a new array object
in AbstractArray at line 48
ArrayIterator
getIterator()
Returns a new iterator from this array
in AbstractArray at line 60
bool
offsetExists(mixed $offset)
Checks whether the specified offset exists in the array
in AbstractArray at line 72
mixed
offsetGet(mixed $offset)
Returns the value stored at the specified offset in the array
at line 25
offsetSet(mixed $offset, mixed $value)
Sets the specified offset in the map with the given value
in AbstractArray at line 100
offsetUnset(mixed $offset)
Removes the specified offset and its value from the map
in AbstractArray at line 112
string
serialize()
Converts this map object to a string when the object is serialized
with serialize()
in AbstractArray at line 123
unserialize(string $serialized)
Re-constructs the object from its serialized form
in AbstractArray at line 134
int
count()
Returns the number of elements contained in this array
in AbstractArray at line 139
void
clear()
Remove all the elements from this array object
in AbstractArray at line 144
toArray()
Returns a native PHP array containing all of the elements in this array object
in AbstractArray at line 149
bool
isEmpty()
Returns true
if this array object contains no elements
at line 37
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 47
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 56
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 64
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 75
mixed
remove(mixed $key)
Removes the mapping for a key from this map if it is present
at line 83
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 94
mixed
replace(mixed $key, mixed $value)
Replaces the entry for the specified key only if it is currently mapped to some value
at line 105
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.