Collection
class Collection implements Countable, JsonSerializable, IteratorAggregate, ArrayAccess (View source)
Properties
| protected array | $storage | The collection store |
Methods
Collection constructor
The first element of the list
The last element of the list
Check if a collection is empty.
Length of the collection
Get the list of values of collection
Get the list of keys of collection
Count the collection element.
Chunk the storage content
To retrieve a value or value collection form instance of collection.
Check existence of a key in the session collection
Browse all the values of the collection
Merge the collection with a painting or other collection
Returns the elements of the collection in table format
Map
Filter
Fill storage
Reduce
Implode
Sum
Max
Max
Returns the key list and return an instance of Collection.
Ignore the key that is given to it and return an instance of Collection.
Reverse collection
Update an existing value in the collection
Deletes the first item in the collection
Deletes the last item in the collection
Returns the elements of the collection
Add after the last item in the collection
__get
__set
Allows to recover a value or value collection.
__isset
__unset
Delete an entry in the collection
__toString
Get the data in JSON format
jsonSerialize
getIterator
offsetExists
offsetGet
offsetSet
Modify an entry in the collection or the addition if not
offsetUnset
Details
__construct(array $storage = [])
Collection constructor
mixed
first()
The first element of the list
mixed
last()
The last element of the list
bool
isEmpty()
Check if a collection is empty.
int
length()
Length of the collection
Collection
values()
Get the list of values of collection
Collection
keys()
Get the list of keys of collection
int
count()
Count the collection element.
Collection
chunk(int $chunk)
Chunk the storage content
Collection
collectify(string $key)
To retrieve a value or value collection form instance of collection.
bool
has(int|string $key, bool $strict = false)
Check existence of a key in the session collection
void
each(callable $cb)
Browse all the values of the collection
Collection
merge(Collection|array $array)
Merge the collection with a painting or other collection
array
toArray()
Returns the elements of the collection in table format
Collection
map(callable $cb)
Map
Collection
filter(callable $cb)
Filter
array
fill(mixed $data, int $offset)
Fill storage
Collection
reduce(callable $cb, mixed $next = null)
Reduce
string
implode(string $sep)
Implode
int|float
sum(callable|null $cb = null)
Sum
int|float
max(callable|null $cb = null)
Max
float|int
min(callable|null $cb = null)
Max
Collection
excepts(array $except)
Returns the key list and return an instance of Collection.
Collection
ignores(array $ignores)
Ignore the key that is given to it and return an instance of Collection.
Collection
reverse()
Reverse collection
bool
update(mixed $key, mixed $data, bool $override = false)
Update an existing value in the collection
Generator
yieldify()
Launches the collection content as generator
mixed
shift()
Deletes the first item in the collection
mixed
pop()
Deletes the last item in the collection
array
all()
Returns the elements of the collection
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
mixed
get(int|string|null $key = null, mixed $default = null)
Allows to recover a value or value collection.
bool
__isset(mixed $name)
__isset
void
__unset(mixed $name)
__unset
Collection
remove(string $key)
Delete an entry in the collection
string
__toString()
__toString
string
toJson(int $option = 0)
Get the data in JSON format
array
jsonSerialize()
jsonSerialize
ArrayIterator
getIterator()
getIterator
bool
offsetExists(mixed $offset)
offsetExists
mixed
offsetGet(mixed $offset)
offsetGet
void
offsetSet(mixed $offset, mixed $value)
offsetSet
mixed
set(string $key, mixed $value)
Modify an entry in the collection or the addition if not
void
offsetUnset(mixed $offset)
offsetUnset