Map
in package
Table of Contents
Properties
- $values : array<string|int, mixed>
Methods
- all() : array<string|int, mixed>
- Returns all values in the map.
- clear() : void
- Clears all values in the map.
- find() : bool
- Checks if the value exists in the map.
- get() : mixed
- Returns the value if it exists in the map, otherwise returns null.
- keys() : array<string|int, mixed>
- Returns the keys and values of the map.
- remove() : void
- Removes the key-value pair from the map.
- set() : void
- Sets a key-value pair in the map.
- size() : int
- Returns the number of key-value pairs in the map.
- values() : array<string|int, mixed>
- Returns the values of the map.
Properties
$values
private
array<string|int, mixed>
$values
= []
Stores unique values in the map.
Methods
all()
Returns all values in the map.
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed>clear()
Clears all values in the map.
public
clear() : void
find()
Checks if the value exists in the map.
public
find(string|int $target) : bool
Parameters
- $target : string|int
-
The value to search for.
Return values
bool —True if the value exists, false otherwise.
get()
Returns the value if it exists in the map, otherwise returns null.
public
get(string|int $target) : mixed
Parameters
- $target : string|int
-
The value to search for.
keys()
Returns the keys and values of the map.
public
keys() : array<string|int, mixed>
Return values
array<string|int, mixed> —An associative array of key-value pairs.
remove()
Removes the key-value pair from the map.
public
remove(string|int $key) : void
Parameters
- $key : string|int
-
The value to remove.
set()
Sets a key-value pair in the map.
public
set(string|int|null $key, string|int|null $value) : void
If the key already exists, it updates the value.
Parameters
- $key : string|int|null
- $value : string|int|null
-
The value to add.
size()
Returns the number of key-value pairs in the map.
public
size() : int
Return values
int —The number of key-value pairs.
values()
Returns the values of the map.
public
values() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of values.