abstract class BaseCollection

Abstract base class to represent collections like vectors or maps.

Traits

Constants

CB_ZERO_ARG

Methods

int
count()

Count how many elements a collection has.

array
toArray()

Convert the collection into a PHP array.

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.

Details

at line 52
abstract int count()

Count how many elements a collection has.

Return Value

int

The number of elements

at line 41
abstract array toArray()

Convert the collection into a PHP array.

Return Value

array

A PHP array representing the collection

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

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

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.