AssociativeArrayMap
class AssociativeArrayMap extends AbstractMap (View source)
AssociativeArrayMap
represents a standard associative array object.
Properties
protected array | $data | The items of this array. | from AbstractArray |
Methods
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.
Details
in AbstractArray at line 35
__construct(array $data = [])
Constructs a new array object.
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.
in AbstractMap at line 34
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.