class Map extends AbstractCollection implements ArrayAccess

Represents a Map

Traits

Methods

__clone()

No description

__construct(array|Iterator $collection = [])

Creates a new Map

void
clear()

Remove all elements from the collection.

bool
contains(mixed $element)

Checks whether the given element is in this array

int
count()

Counts the array

current()

No description

void
each(callable $callback)

Iterates the map and calls the callback function with the current key and value as parameters

bool
every(callable $callback)

Tests whether all elements in the array pass the test implemented by the provided function.

filter(callable $callback)

Filters elements using a callback function

mixed|null
find(array ...$arguments)

Searches the array with a given callback and returns the first element if found.

mixed|null
findAll(array ...$arguments)

Searches the array with a given callback and returns all matching elements.

mixed|null
findKey(array ...$arguments)

Searches the collection with a given callback and returns the key for the first element if found.

mixed|null
findLast(array ...$arguments)

Searches the array with a given callback and returns the last element if found.

mixed|null
findLastKey(array ...$arguments)

Searches the collection with a given callback and returns the key for the last element if found.

mixed
get(string|Text $key)

Returns the element for the given key

mixed
getKey(mixed $value)

Returns the key for the given value

bool
has(string|Text $key)

Returns whether the key exist.

bool
isEmpty()

Checks whether this array is empty

key()

No description

Set
keys()

Returns all keys as Set

map(callable $callback)

Applies the callback to the elements

next()

No description

offsetExists($offset)

No description

offsetGet($offset)

No description

offsetSet($offset, $value)

No description

offsetUnset($offset)

No description

Map
remove(string|Text $key)

Removes and returns an element from the map by the given key. Returns null if the key does not exist.

rewind()

No description

bool
search(array ...$arguments)

Searches the array for query using the callback function on each element

Map
set(string|Text $key, mixed $element)

Sets an element with the given key on that map

Map
setAll(array|Iterator $collection)

Sets many elements on that map

int
size()

Return the size of the array.

bool
some(callable $callback)

Tests whether at least one element in the array passes the test implemented by the provided function.

sort(Comparator|callable $cmp = null)

Sorts the map

sortAssoc(Comparator|callable $cmp = null)

Sorts the array and persisting key-value pairs

sortKeys(Comparator|callable $cmp = null)

Sorts the array by keys

array
toArray()

Returns the php array type

bool
valid()

No description

values()

Returns all values as ArrayList

Details

in AbstractArray at line 44
__clone()

at line 31
__construct(array|Iterator $collection = [])

Creates a new Map

Parameters

array|Iterator $collection

in AbstractCollection at line 24
void clear()

Remove all elements from the collection.

Return Value

void

in AbstractArray at line 55
bool contains(mixed $element)

Checks whether the given element is in this array

Parameters

mixed $element

Return Value

bool

in AbstractArray at line 30
int count()

Counts the array

Return Value

int the amount of items

in AbstractCollection at line 38
current()

at line 173
void each(callable $callback)

Iterates the map and calls the callback function with the current key and value as parameters

Parameters

callable $callback

Return Value

void

in AbstractArray at line 246
bool every(callable $callback)

Tests whether all elements in the array pass the test implemented by the provided function.

Returns true for an empty array.

Parameters

callable $callback

Return Value

bool

in AbstractArray at line 280
AbstractArray filter(callable $callback)

Filters elements using a callback function

Parameters

callable $callback the filter function

Return Value

AbstractArray

in AbstractArray at line 85
mixed|null find(array ...$arguments)

Searches the array with a given callback and returns the first element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

in AbstractArray at line 144
mixed|null findAll(array ...$arguments)

Searches the array with a given callback and returns all matching elements.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

at line 196
mixed|null findKey(array ...$arguments)

Searches the collection with a given callback and returns the key for the first element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the key or null if it hasn't been found

in AbstractArray at line 114
mixed|null findLast(array ...$arguments)

Searches the array with a given callback and returns the last element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

at line 219
mixed|null findLastKey(array ...$arguments)

Searches the collection with a given callback and returns the key for the last element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the key or null if it hasn't been found

at line 70
mixed get(string|Text $key)

Returns the element for the given key

Parameters

string|Text $key

Return Value

mixed

at line 84
mixed getKey(mixed $value)

Returns the key for the given value

Parameters

mixed $value the value

Return Value

mixed

at line 151
bool has(string|Text $key)

Returns whether the key exist.

Parameters

string|Text $key

Return Value

bool

in AbstractArray at line 64
bool isEmpty()

Checks whether this array is empty

Return Value

bool

in AbstractCollection at line 45
key()

at line 131
Set keys()

Returns all keys as Set

Return Value

Set the map's keys

in AbstractArray at line 291
AbstractArray map(callable $callback)

Applies the callback to the elements

Parameters

callable $callback the applied callback function

Return Value

AbstractArray

in AbstractCollection at line 52
next()

at line 237
offsetExists($offset)

Parameters

$offset

at line 251
offsetGet($offset)

Parameters

$offset

at line 228
offsetSet($offset, $value)

Parameters

$offset
$value

at line 244
offsetUnset($offset)

Parameters

$offset

at line 117
Map remove(string|Text $key)

Removes and returns an element from the map by the given key. Returns null if the key does not exist.

Parameters

string|Text $key

Return Value

Map

in AbstractCollection at line 31
rewind()

Searches the array for query using the callback function on each element

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- search($query, callback)
- search(callback)

Parameters

array ...$arguments

Return Value

bool

at line 56
Map set(string|Text $key, mixed $element)

Sets an element with the given key on that map

Parameters

string|Text $key
mixed $element

Return Value

Map $this

at line 101
Map setAll(array|Iterator $collection)

Sets many elements on that map

Parameters

array|Iterator $collection

Return Value

Map $this

in AbstractArray at line 40
int size()

Return the size of the array.

Alias of count

Return Value

int

in AbstractArray at line 264
bool some(callable $callback)

Tests whether at least one element in the array passes the test implemented by the provided function.

Returns false for an empty array.

Parameters

callable $callback

Return Value

bool

at line 164
AbstractArray sort(Comparator|callable $cmp = null)

Sorts the map

Parameters

Comparator|callable $cmp

Return Value

AbstractArray

in SortAssocPart at line 23
SortAssocPart sortAssoc(Comparator|callable $cmp = null)

Sorts the array and persisting key-value pairs

Parameters

Comparator|callable $cmp

Return Value

SortAssocPart

in SortAssocPart at line 36
SortAssocPart sortKeys(Comparator|callable $cmp = null)

Sorts the array by keys

Parameters

Comparator|callable $cmp

Return Value

SortAssocPart

in AbstractArray at line 191
array toArray()

Returns the php array type

Return Value

array

in AbstractCollection at line 59
bool valid()

Return Value

bool

at line 140
ArrayList values()

Returns all values as ArrayList

Return Value

ArrayList the map's values