Properties

$data

$data : array

Array data

Type

array

Methods

__construct()

__construct(mixed  $data = array()) 

Constructor

Instantiate the collection object

Parameters

mixed $data

count()

count() : integer

Method to get the count of data in the collection

Returns

integer

first()

first() : mixed

Get the first item of the collection

Returns

mixed

next()

next() : mixed

Get the next item of the collection

Returns

mixed

current()

current() : mixed

Get the current item of the collection

Returns

mixed

last()

last() : mixed

Get the last item of the collection

Returns

mixed

key()

key() : mixed

Get the key of the current item of the collection

Returns

mixed

contains()

contains(mixed  $key, boolean  $strict = false) : boolean

Determine if an item exists in the collection

Parameters

mixed $key
boolean $strict

Returns

boolean

each()

each(callable  $callback) : \Pop\Utils\Collection

Execute a callback over each item

Parameters

callable $callback

Returns

\Pop\Utils\Collection

every()

every(integer  $step, integer  $offset) : \Pop\Utils\Collection

Create a new collection from every n-th element

Parameters

integer $step
integer $offset

Returns

\Pop\Utils\Collection

filter()

filter(callable  $callback = null, integer  $flag) : \Pop\Utils\Collection

Apply filter to the collection

Parameters

callable $callback
integer $flag

Returns

\Pop\Utils\Collection

map()

map(callable  $callback, integer  $flag) : \Pop\Utils\Collection

Apply map to the collection

Parameters

callable $callback
integer $flag

Returns

\Pop\Utils\Collection

has()

has(mixed  $key) : boolean

Determine if the key exists

Parameters

mixed $key

Returns

boolean

isEmpty()

isEmpty() : boolean

Determine if the collection is empty or not

Returns

boolean

keys()

keys() : \Pop\Utils\Collection

Get the keys of the collection data

Returns

\Pop\Utils\Collection

values()

values() : \Pop\Utils\Collection

Get the values of the collection data

Returns

\Pop\Utils\Collection

merge()

merge(mixed  $data, boolean  $recursive = false) : \Pop\Utils\Collection

Merge the collection with the passed data

Parameters

mixed $data
boolean $recursive

Returns

\Pop\Utils\Collection

forPage()

forPage(integer  $page, integer  $perPage) : \Pop\Utils\Collection

Slice the collection for a page

Parameters

integer $page
integer $perPage

Returns

\Pop\Utils\Collection

pop()

pop() : mixed

Get and remove the last item from the collection

Returns

mixed

push()

push(mixed  $value) : \Pop\Utils\Collection

Push an item onto the end of the collection.

Parameters

mixed $value

Returns

\Pop\Utils\Collection

shift()

shift() : mixed

Get and remove the first item from the collection

Returns

mixed

slice()

slice(integer  $offset, integer  $length = null) : \Pop\Utils\Collection

Slice the collection

Parameters

integer $offset
integer $length

Returns

\Pop\Utils\Collection

splice()

splice(integer  $offset, integer|null  $length = null, mixed  $replacement = array()) : \Pop\Utils\Collection

Splice a portion of the collection

Parameters

integer $offset
integer|null $length
mixed $replacement

Returns

\Pop\Utils\Collection

sort()

sort(callable|null  $callback = null, integer  $flags = SORT_REGULAR) : \Pop\Utils\Collection

Sort data

Parameters

callable|null $callback
integer $flags

Returns

\Pop\Utils\Collection

sortByAsc()

sortByAsc(integer  $flags = SORT_REGULAR) : \Pop\Utils\Collection

Sort the collection ascending

Parameters

integer $flags

Returns

\Pop\Utils\Collection

sortByDesc()

sortByDesc(integer  $flags = SORT_REGULAR) : \Pop\Utils\Collection

Sort the collection descending

Parameters

integer $flags

Returns

\Pop\Utils\Collection

toArray()

toArray(array  $options = array()) : array

Method to get collection object as an array

Parameters

array $options

Returns

array

getIterator()

getIterator() : \ArrayIterator

Method to iterate over the collection

Returns

\ArrayIterator

__set()

__set(string  $name, mixed  $value) : void

Magic method to set the property to the value of $this->data[$name]

Parameters

string $name
mixed $value

__get()

__get(string  $name) : mixed

Magic method to return the value of $this->data[$name]

Parameters

string $name

Returns

mixed

__isset()

__isset(string  $name) : boolean

Magic method to return the isset value of $this->data[$name]

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $name) : void

Magic method to unset $this->data[$name]

Parameters

string $name

offsetExists()

offsetExists(mixed  $offset) : boolean

ArrayAccess offsetExists

Parameters

mixed $offset

Returns

boolean

offsetGet()

offsetGet(mixed  $offset) : mixed

ArrayAccess offsetGet

Parameters

mixed $offset

Returns

mixed

offsetSet()

offsetSet(mixed  $offset, mixed  $value) : void

ArrayAccess offsetSet

Parameters

mixed $offset
mixed $value

offsetUnset()

offsetUnset(mixed  $offset) : void

ArrayAccess offsetUnset

Parameters

mixed $offset

getItems()

getItems() : array

Method to get collection object items

Returns

array

getDataAsArray()

getDataAsArray(mixed  $data) : array

Method to get data as an array

Parameters

mixed $data

Returns

array