abstract class BaseMap extends BaseCollection implements ArrayAccess, IteratorAggregate

Abstract base class to represent hashmaps / associative arrays / dictionaries.

It also provides a concrete implementation for ArrayAccess interface.

Traits

Constants

CB_ZERO_ARG

Methods

int
count()

No description

array
toArray()

No description

mixed
first()

No description

mixed
firstOr(mixed $default)

No description

bool
any(callable $callable)

Determines if at least an element of the collection satisfies a condition.

bool
all(callable $callable)

Determines if all elements of the collection satisfies a condition.

static BaseCollection
from(iterable $items)

Create a new collection instance from the specified iterable.

bool
isEmpty()

Determine if a collection is empty.

mixed
get(mixed $key)

Get the value at the specified key.

mixed
getOr(mixed $key, mixed $defaultValue)

Get the value at the specified key.

set(mixed $key, mixed $value)

Set the specified value at the specified key.

unset(mixed $key)

This method returns the instance itself, so you can use it in fluent pattern.

bool
has(mixed $key)

Determine if the specified key exists.

bool
contains(mixed $value)

Determine if the specified value exists.

bool
offsetExists(mixed $offset)

No description

mixed
offsetGet(mixed $offset)

No description

void
offsetSet(mixed $offset, mixed $value)

Assign a value to the specified offset

void
offsetUnset(mixed $offset)

No description

Details

in WithCollection at line 12
abstract int count()

No description

Return Value

int

in WithCollection at line 13
abstract array toArray()

No description

Return Value

array

in WithCollection at line 15
mixed first()

No description

Return Value

mixed

in WithCollection at line 23
mixed firstOr(mixed $default)

No description

Parameters

mixed $default

Return Value

mixed

in WithCollection at line 45
bool any(callable $callable)

Determines if at least an element of the collection satisfies a condition.

The execution of callbacks stop after a callable returned true.

Parameters

callable $callable

A method returning a boolean with key and value or only value as arguments.

Return Value

bool

True if callback is true for at least one of the elements

Exceptions

ReflectionException

in WithCollection at line 78
bool all(callable $callable)

Determines if all elements of the collection satisfies a condition.

The execution of callbacks stop after a callable returned false.

Parameters

callable $callable

A method returning a boolean with key and value or only value as arguments.

Return Value

bool

True if callback is true for all the elements

Exceptions

ReflectionException

in BaseCollection at line 24
abstract static BaseCollection from(iterable $items)

Create a new collection instance from the specified iterable.

Parameters

iterable $items

The elements to put in the new collection

Return Value

BaseCollection

The collection with the elements from the iterable

in BaseCollection at line 59
abstract bool isEmpty()

Determine if a collection is empty.

Return Value

bool

true if the collection has 0 element; if not, false.

at line 28
abstract mixed get(mixed $key)

Get the value at the specified key.

Parameters

mixed $key

The key

Return Value

mixed

The value

at line 38
abstract mixed getOr(mixed $key, mixed $defaultValue)

Get the value at the specified key.

Parameters

mixed $key

The key

mixed $defaultValue

The value to return if the key doesn't exist.

Return Value

mixed

When the key exists, the value at that key; otherwise, the default value

at line 50
abstract BaseMap set(mixed $key, mixed $value)

Set the specified value at the specified key.

This method returns the instance itself, so you can use it in fluent pattern.

Parameters

mixed $key

The key

mixed $value

The value

Return Value

BaseMap

The map

at line 59
abstract BaseMap unset(mixed $key)

This method returns the instance itself, so you can use it in fluent pattern.

Parameters

mixed $key

Return Value

BaseMap

The map

at line 68
abstract bool has(mixed $key)

Determine if the specified key exists.

Parameters

mixed $key

The key to fetch

Return Value

bool

true if the key exists; otherwise, false.

at line 77
abstract bool contains(mixed $value)

Determine if the specified value exists.

Parameters

mixed $value

Return Value

bool

true if the value exists; otherwise, false

at line 90
bool offsetExists(mixed $offset)

No description

Parameters

mixed $offset

The offset to assign the value to

Return Value

bool

true if the offset exists; otherwise, false

at line 100
mixed offsetGet(mixed $offset)

No description

Parameters

mixed $offset

The offset to assign the value to

Return Value

mixed

The value at that offset

at line 112
void offsetSet(mixed $offset, mixed $value)

Assign a value to the specified offset

Parameters

mixed $offset

The offset to assign the value to

mixed $value

The value to set

Return Value

void

at line 121
void offsetUnset(mixed $offset)

No description

Parameters

mixed $offset

The offset to assign the value to

Return Value

void