class Collection implements Countable, JsonSerializable, IteratorAggregate, ArrayAccess (View source)

Properties

protected array $storage

The collection store

Methods

__construct(array $storage = [])

Collection constructor

mixed
first()

The first element of the list

array
last()

The last element of the list

bool
has(string $key, bool $strict = false)

Check existence of a key in the session collection

bool
isEmpty()

Check if a collection is empty.

mixed
get(string $key = null, mixed $default = null)

Allows to recover a value or value collection.

values()

Get the list of values of collection

keys()

Get the list of keys of collection

int
count()

Count the collection element.

collectionify(string $key)

To retrieve a value or value collection form d'instance de collection.

delete(string $key)

Delete an entry in the collection

mixed
set(mixed $key, mixed $value)

Modify an entry in the collection or the addition if not

void
each(callable $cb)

Browse all the values of the collection

merge(Collection|array $array)

Merge the collection with a painting or other collection

map(callable $cb)

Map

filter(callable $cb)

Filter

mixed
fill(mixed $data, int $offset)

Fill storage

reduce(callable $cb, mixed $next = null)

Reduce

string
implode(string $sep)

Implode

int|float
sum(callable $cb = null)

Sum

int|float
max(callable|null $cb = null)

Max

int|float
min(callable|null $cb = null)

Max

excepts(array $except)

Returns the key list and return an instance of Collection.

ignores(array $ignores)

Ignore the key that is given to it and return an instance of Collection.

reverse()

Reverse collection

bool
update(mixed $key, mixed $data, bool $override = false)

Update an existing value in the collection

yieldify()

Launches the collection content as generator

string
toJson(int $option = 0)

Get the data in JSON format

int
length()

Length of the collection

mixed
shift()

Deletes the first item in the collection

mixed
pop()

Deletes the last item in the collection

array
toArray()

Returns the elements of the collection in table format

array
all()

Returns the elements of the collection

push(mixed $value, mixed $key = null)

Add after the last item in the collection

mixed
__get(mixed $name)

__get

void
__set(mixed $name, mixed $value)

__set

bool
__isset(mixed $name)

__isset

void
__unset(mixed $name)

__unset

string
__toString()

__toString

string
jsonSerialize()

jsonSerialize

getIterator()

getIterator

bool
offsetExists(mixed $offset)

offsetExists

mixed
offsetGet(mixed $offset)

offsetGet

void
offsetSet(mixed $offset, mixed $value)

offsetSet

void
offsetUnset(mixed $offset)

offsetUnset

Details

__construct(array $storage = [])

Collection constructor

Parameters

array $storage

mixed first()

The first element of the list

Return Value

mixed

array last()

The last element of the list

Return Value

array

bool has(string $key, bool $strict = false)

Check existence of a key in the session collection

Parameters

string $key
bool $strict

Return Value

bool

bool isEmpty()

Check if a collection is empty.

Return Value

bool

mixed get(string $key = null, mixed $default = null)

Allows to recover a value or value collection.

Parameters

string $key
mixed $default

Return Value

mixed

Collection values()

Get the list of values of collection

Return Value

Collection

Collection keys()

Get the list of keys of collection

Return Value

Collection

int count()

Count the collection element.

Return Value

int

Collection collectionify(string $key)

To retrieve a value or value collection form d'instance de collection.

Parameters

string $key

Return Value

Collection

Collection delete(string $key)

Delete an entry in the collection

Parameters

string $key

Return Value

Collection

mixed set(mixed $key, mixed $value)

Modify an entry in the collection or the addition if not

Parameters

mixed $key
mixed $value

Return Value

mixed

void each(callable $cb)

Browse all the values of the collection

Parameters

callable $cb

Return Value

void

Collection merge(Collection|array $array)

Merge the collection with a painting or other collection

Parameters

Collection|array $array

Return Value

Collection

Exceptions

ErrorException

Collection map(callable $cb)

Map

Parameters

callable $cb

Return Value

Collection

Collection filter(callable $cb)

Filter

Parameters

callable $cb

Return Value

Collection

mixed fill(mixed $data, int $offset)

Fill storage

Parameters

mixed $data
int $offset

Return Value

mixed

Collection reduce(callable $cb, mixed $next = null)

Reduce

Parameters

callable $cb
mixed $next

Return Value

Collection

string implode(string $sep)

Implode

Parameters

string $sep

Return Value

string

int|float sum(callable $cb = null)

Sum

Parameters

callable $cb

Return Value

int|float

int|float max(callable|null $cb = null)

Max

Parameters

callable|null $cb

Return Value

int|float

int|float min(callable|null $cb = null)

Max

Parameters

callable|null $cb

Return Value

int|float

Collection excepts(array $except)

Returns the key list and return an instance of Collection.

Parameters

array $except

Return Value

Collection

Collection ignores(array $ignores)

Ignore the key that is given to it and return an instance of Collection.

Parameters

array $ignores

Return Value

Collection

Collection reverse()

Reverse collection

Return Value

Collection

bool update(mixed $key, mixed $data, bool $override = false)

Update an existing value in the collection

Parameters

mixed $key
mixed $data
bool $override

Return Value

bool

Generator yieldify()

Launches the collection content as generator

Return Value

Generator

string toJson(int $option = 0)

Get the data in JSON format

Parameters

int $option

Return Value

string

int length()

Length of the collection

Return Value

int

mixed shift()

Deletes the first item in the collection

Return Value

mixed

mixed pop()

Deletes the last item in the collection

Return Value

mixed

array toArray()

Returns the elements of the collection in table format

Return Value

array

array all()

Returns the elements of the collection

Return Value

array

Collection push(mixed $value, mixed $key = null)

Add after the last item in the collection

Parameters

mixed $value
mixed $key

Return Value

Collection

mixed __get(mixed $name)

__get

Parameters

mixed $name

Return Value

mixed

void __set(mixed $name, mixed $value)

__set

Parameters

mixed $name
mixed $value

Return Value

void

bool __isset(mixed $name)

__isset

Parameters

mixed $name

Return Value

bool

void __unset(mixed $name)

__unset

Parameters

mixed $name

Return Value

void

string __toString()

__toString

Return Value

string

string jsonSerialize()

jsonSerialize

Return Value

string

ArrayIterator getIterator()

getIterator

Return Value

ArrayIterator

bool offsetExists(mixed $offset)

offsetExists

Parameters

mixed $offset

Return Value

bool

mixed offsetGet(mixed $offset)

offsetGet

Parameters

mixed $offset

Return Value

mixed

void offsetSet(mixed $offset, mixed $value)

offsetSet

Parameters

mixed $offset
mixed $value

Return Value

void

void offsetUnset(mixed $offset)

offsetUnset

Parameters

mixed $offset

Return Value

void