Collection
extends AbstractArray
in package
Pop utils array collection class
Tags
Table of Contents
Properties
- $data : mixed
- Array data
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a value
- __isset() : bool
- Is value set
- __set() : static
- Magic method to set the property to the value of $this->data[$name]
- __unset() : void
- Unset a value
- column() : Collection
- Get the values of a column
- contains() : bool
- Determine if an item exists in the array
- count() : int
- Method to get the count of data in the collection
- current() : mixed
- Get the current item of the array
- 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 array
- flip() : Collection
- Flip the data in the collection
- forPage() : Collection
- Slice the collection for a page
- getIterator() : ArrayIterator
- Method to iterate over the array object
- has() : bool
- Determine if the key exists
- isEmpty() : bool
- Determine if the collection is empty or not
- join() : string
- Join the array values into a string
- key() : mixed
- Get the key of the current item of the array
- keys() : Collection
- Get the keys of the collection data
- ksort() : array<string|int, mixed>
- Sort array by keys
- ksortDesc() : static
- Sort array by keys, descending
- last() : mixed
- Get the last item of the array
- map() : Collection
- Apply map to the collection
- merge() : Collection
- Merge the collection with the passed data
- next() : mixed
- Get the next item of the array
- 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() : array<string|int, mixed>
- Sort array
- sortDesc() : static
- Sort array descending
- splice() : Collection
- Splice a portion of the collection
- split() : static
- Split a string into an array object
- toArray() : array<string|int, mixed>
- Get the values as an array
- uksort() : array<string|int, mixed>
- Sort array by user-defined callback using keys
- usort() : static
- Sort array by user-defined callback
- 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
mixed
$data
= null
Methods
__construct()
Constructor
public
__construct([mixed $data = [] ]) : mixed
Instantiate the collection object
Parameters
- $data : mixed = []
__get()
Get a value
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Is value set
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|null $name = null ][, mixed $value = null ]) : static
Parameters
- $name : string|null = null
- $value : mixed = null
Return values
static__unset()
Unset a value
public
__unset(string $name) : void
Parameters
- $name : string
column()
Get the values of a column
public
column(string $column) : Collection
Parameters
- $column : string
Return values
Collectioncontains()
Determine if an item exists in the array
public
contains(mixed $key[, bool $strict = false ]) : bool
Parameters
- $key : mixed
- $strict : bool = false
Return values
boolcount()
Method to get the count of data in the collection
public
count() : int
Return values
intcurrent()
Get the current item of the array
public
current() : mixed
each()
Execute a callback over each item
public
each(callable $callback) : Collection
Parameters
- $callback : callable
Return values
Collectionevery()
Create a new collection from every n-th element
public
every(int $step[, int $offset = 0 ]) : Collection
Parameters
- $step : int
- $offset : int = 0
Return values
Collectionfilter()
Apply filter to the collection
public
filter([callable|null $callback = null ][, int $flag = 0 ]) : Collection
Parameters
- $callback : callable|null = null
- $flag : int = 0
Return values
Collectionfirst()
Get the first item of the array
public
first() : mixed
flip()
Flip the data in the collection
public
flip() : Collection
Return values
CollectionforPage()
Slice the collection for a page
public
forPage(int $page, int $perPage) : Collection
Parameters
- $page : int
- $perPage : int
Return values
CollectiongetIterator()
Method to iterate over the array object
public
getIterator() : ArrayIterator
Return values
ArrayIteratorhas()
Determine if the key exists
public
has(mixed $key) : bool
Parameters
- $key : mixed
Return values
boolisEmpty()
Determine if the collection is empty or not
public
isEmpty() : bool
Return values
booljoin()
Join the array values into a string
public
join(string $glue[, string $finalGlue = '' ]) : string
Parameters
- $glue : string
- $finalGlue : string = ''
Return values
stringkey()
Get the key of the current item of the array
public
key() : mixed
keys()
Get the keys of the collection data
public
keys() : Collection
Return values
Collectionksort()
Sort array by keys
public
ksort([int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $descending : bool = false
Return values
array<string|int, mixed>ksortDesc()
Sort array by keys, descending
public
ksortDesc([int $flags = SORT_REGULAR ]) : static
Parameters
- $flags : int = SORT_REGULAR
Return values
staticlast()
Get the last item of the array
public
last() : mixed
map()
Apply map to the collection
public
map(callable $callback) : Collection
Parameters
- $callback : callable
Return values
Collectionmerge()
Merge the collection with the passed data
public
merge(mixed $data[, bool $recursive = false ]) : Collection
Parameters
- $data : mixed
- $recursive : bool = false
Return values
Collectionnext()
Get the next item of the array
public
next() : mixed
offsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
pop()
Get and remove the last item from the collection
public
pop() : mixed
push()
Push an item onto the end of the collection.
public
push(mixed $value) : Collection
Parameters
- $value : mixed
Return values
Collectionshift()
Get and remove the first item from the collection
public
shift() : mixed
slice()
Slice the collection
public
slice(int $offset[, int $length = null ]) : Collection
Parameters
- $offset : int
- $length : int = null
Return values
Collectionsort()
Sort array
public
sort([int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
- $descending : bool = false
Return values
array<string|int, mixed>sortDesc()
Sort array descending
public
sortDesc([int $flags = SORT_REGULAR ][, bool $assoc = true ]) : static
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
Return values
staticsplice()
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
Collectionsplit()
Split a string into an array object
public
static split(string $string, string $separator[, int $limit = PHP_INT_MAX ]) : static
Parameters
- $string : string
- $separator : string
- $limit : int = PHP_INT_MAX
Return values
statictoArray()
Get the values as an array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>uksort()
Sort array by user-defined callback using keys
public
uksort(mixed $callback) : array<string|int, mixed>
Parameters
- $callback : mixed
Return values
array<string|int, mixed>usort()
Sort array by user-defined callback
public
usort(mixed $callback[, bool $assoc = true ]) : static
Parameters
- $callback : mixed
- $assoc : bool = true
Return values
staticvalues()
Get the values of the collection data
public
values() : Collection
Return values
CollectiongetDataAsArray()
Method to get data as an array
protected
getDataAsArray(mixed $data) : array<string|int, mixed>
Parameters
- $data : mixed