Map.php
\Ulrichsg\Collections\Map
Package: A simple key-value map. Its main advantage over plain arrays is that you never have to call isset() to avoid
warnings. Supports square-bracket syntax and foreach loops.
- Implements
- Children
- \Ulrichsg\Collections\NumberMap
- License
- MIT
- Link
- https://github.com/ulrichsg/php-collections
- Version
-
Methods



__construct(array $data = array()) : void
Creates a new map with the given array as its contents. Omitting the argument creates an empty map.
ParametersName | Type | Description |
---|
$data | array | |
---|



get(mixed $key, mixed $default = null) : mixed
If the map contains the given key, returns the associated value. Otherwise, returns the default value.
ParametersName | Type | Description |
---|
$key | mixed | |
---|
$default | mixed | |
---|
Returns 


getIterator() : \ArrayIterator
Returns an iterator over the map.
ReturnsType | Description |
---|
\ArrayIterator | |



hasKey(mixed $key) : bool
Returns true if the map contains the given key, false otherwise.
ParametersName | Type | Description |
---|
$key | mixed | |
---|
Returns 


remove(mixed $key) : void
Removes the given key and its associated value from the map. Does nothing if the key is not in the map.
ParametersName | Type | Description |
---|
$key | mixed | |
---|



set(mixed $key, mixed $value) : void
Puts the given key-value pair into the map.
ParametersName | Type | Description |
---|
$key | mixed | |
---|
$value | mixed | |
---|