Collection
extends AbstractArray
in package
implements
ArrayAccess, Countable, IteratorAggregate
Pop utils array object class
Tags
Interfaces, Classes and Traits
- ArrayAccess
- Countable
- IteratorAggregate
Table of Contents
- $data : array<string|int, mixed>
- Array data
- __construct() : mixed
- Constructor
- __get() : mixed
- Magic method to return the value of $this->data[$name]
- __isset() : bool
- Magic method to return the isset value of $this->data[$name]
- __set() : void
- Magic method to set the property to the value of $this->data[$name]
- __unset() : void
- Magic method to unset $this->data[$name]
- contains() : bool
- Determine if an item exists in the collection
- count() : int
- Method to get the count of data in the collection
- current() : mixed
- Get the current item of the collection
- each() : Collection
- Execute a callback over each item
- every() : Collection
- Create a new collection from every n-th element
- filter() : Collection
- Apply filter to the collection
- first() : mixed
- Get the first item of the collection
- flip() : Collection
- Flip the data in the collection
- forPage() : Collection
- Slice the collection for a page
- getIterator() : ArrayIterator
- Method to iterate over the collection
- has() : bool
- Determine if the key exists
- isEmpty() : bool
- Determine if the collection is empty or not
- key() : mixed
- Get the key of the current item of the collection
- keys() : Collection
- Get the keys of the collection data
- last() : mixed
- Get the last item of the collection
- map() : Collection
- Apply map to the collection
- merge() : Collection
- Merge the collection with the passed data
- next() : mixed
- Get the next item of the collection
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- pop() : mixed
- Get and remove the last item from the collection
- push() : Collection
- Push an item onto the end of the collection.
- shift() : mixed
- Get and remove the first item from the collection
- slice() : Collection
- Slice the collection
- sort() : Collection
- Sort data
- sortByAsc() : Collection
- Sort the collection ascending
- sortByDesc() : Collection
- Sort the collection descending
- splice() : Collection
- Splice a portion of the collection
- toArray() : array<string|int, mixed>
- Method to get collection object as an array
- values() : Collection
- Get the values of the collection data
- getDataAsArray() : array<string|int, mixed>
- Method to get data as an array
Properties
$data
Array data
protected
array<string|int, mixed>
$data
= []
Methods
__construct()
Constructor
public
__construct([mixed $data = [] ]) : mixed
Instantiate the collection object
Parameters
- $data : mixed = []
Return values
mixed —__get()
Magic method to return the value of $this->data[$name]
public
__get(string $name) : mixed
Parameters
- $name : string
Return values
mixed —__isset()
Magic method to return the isset value of $this->data[$name]
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool —__set()
Magic method to set the property to the value of $this->data[$name]
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Return values
void —__unset()
Magic method to unset $this->data[$name]
public
__unset(string $name) : void
Parameters
- $name : string
Return values
void —contains()
Determine if an item exists in the collection
public
contains(mixed $key[, bool $strict = false ]) : bool
Parameters
- $key : mixed
- $strict : bool = false
Return values
bool —count()
Method to get the count of data in the collection
public
count() : int
Return values
int —current()
Get the current item of the collection
public
current() : mixed
Return values
mixed —each()
Execute a callback over each item
public
each(callable $callback) : Collection
Parameters
- $callback : callable
Return values
Collection —every()
Create a new collection from every n-th element
public
every(int $step, int $offset) : Collection
Parameters
- $step : int
- $offset : int
Return values
Collection —filter()
Apply filter to the collection
public
filter([callable $callback = null ], int $flag) : Collection
Parameters
- $callback : callable = null
- $flag : int
Return values
Collection —first()
Get the first item of the collection
public
first() : mixed
Return values
mixed —flip()
Flip the data in the collection
public
flip() : Collection
Return values
Collection —forPage()
Slice the collection for a page
public
forPage(int $page, int $perPage) : Collection
Parameters
- $page : int
- $perPage : int
Return values
Collection —getIterator()
Method to iterate over the collection
public
getIterator() : ArrayIterator
Return values
ArrayIterator —has()
Determine if the key exists
public
has(mixed $key) : bool
Parameters
- $key : mixed
Return values
bool —isEmpty()
Determine if the collection is empty or not
public
isEmpty() : bool
Return values
bool —key()
Get the key of the current item of the collection
public
key() : mixed
Return values
mixed —keys()
Get the keys of the collection data
public
keys() : Collection
Return values
Collection —last()
Get the last item of the collection
public
last() : mixed
Return values
mixed —map()
Apply map to the collection
public
map(callable $callback, int $flag) : Collection
Parameters
- $callback : callable
- $flag : int
Return values
Collection —merge()
Merge the collection with the passed data
public
merge(mixed $data[, bool $recursive = false ]) : Collection
Parameters
- $data : mixed
- $recursive : bool = false
Return values
Collection —next()
Get the next item of the collection
public
next() : mixed
Return values
mixed —offsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
bool —offsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Return values
void —offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Return values
void —pop()
Get and remove the last item from the collection
public
pop() : mixed
Return values
mixed —push()
Push an item onto the end of the collection.
public
push(mixed $value) : Collection
Parameters
- $value : mixed
Return values
Collection —shift()
Get and remove the first item from the collection
public
shift() : mixed
Return values
mixed —slice()
Slice the collection
public
slice(int $offset[, int $length = null ]) : Collection
Parameters
- $offset : int
- $length : int = null
Return values
Collection —sort()
Sort data
public
sort([callable|null $callback = null ][, int $flags = SORT_REGULAR ]) : Collection
Parameters
- $callback : callable|null = null
- $flags : int = SORT_REGULAR
Return values
Collection —sortByAsc()
Sort the collection ascending
public
sortByAsc([int $flags = SORT_REGULAR ]) : Collection
Parameters
- $flags : int = SORT_REGULAR
Return values
Collection —sortByDesc()
Sort the collection descending
public
sortByDesc([int $flags = SORT_REGULAR ]) : Collection
Parameters
- $flags : int = SORT_REGULAR
Return values
Collection —splice()
Splice a portion of the collection
public
splice(int $offset[, int|null $length = null ][, mixed $replacement = [] ]) : Collection
Parameters
- $offset : int
- $length : int|null = null
- $replacement : mixed = []
Return values
Collection —toArray()
Method to get collection object as an array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —values()
Get the values of the collection data
public
values() : Collection
Return values
Collection —getDataAsArray()
Method to get data as an array
protected
getDataAsArray(mixed $data) : array<string|int, mixed>
Parameters
- $data : mixed