Properties

$items

$items : array

Array of items in the collection

Type

array

Methods

__construct()

__construct(mixed  $items = array()) 

Constructor

Instantiate the collection object

Parameters

mixed $items

count()

count() : integer

Method to get the count of items 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\Db\Record\Collection

Execute a callback over each item

Parameters

callable $callback

Returns

\Pop\Db\Record\Collection

every()

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

Create a new collection from every n-th element

Parameters

integer $step
integer $offset

Returns

\Pop\Db\Record\Collection

filter()

filter(callable|null  $callback, integer  $flag) : \Pop\Db\Record\Collection

Apply filter to the collection

Parameters

callable|null $callback
integer $flag

Returns

\Pop\Db\Record\Collection

has()

has(mixed  $key) : boolean

Determine if the key exists

Parameters

mixed $key

Returns

boolean

intersect()

intersect(mixed  $items) : \Pop\Db\Record\Collection

Intersect the collection with the passed items

Parameters

mixed $items

Returns

\Pop\Db\Record\Collection

isEmpty()

isEmpty() : boolean

Determine if the collection is empty or not

Returns

boolean

merge()

merge(mixed  $items, boolean  $recursive = false) : \Pop\Db\Record\Collection

Merge the collection with the passed items

Parameters

mixed $items
boolean $recursive

Returns

\Pop\Db\Record\Collection

forPage()

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

Slice the collection for a page

Parameters

integer $page
integer $perPage

Returns

\Pop\Db\Record\Collection

pop()

pop() : mixed

Get and remove the last item from the collection

Returns

mixed

push()

push(mixed  $value) : \Pop\Db\Record\Collection

Push an item onto the end of the collection.

Parameters

mixed $value

Returns

\Pop\Db\Record\Collection

search()

search(mixed  $value, boolean  $strict = false) : mixed

Search the collection and return the key on success

Parameters

mixed $value
boolean $strict

Returns

mixed

shift()

shift() : mixed

Get and remove the first item from the collection

Returns

mixed

slice()

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

Slice the collection

Parameters

integer $offset
integer $length

Returns

\Pop\Db\Record\Collection

splice()

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

Splice a portion of the collection

Parameters

integer $offset
integer|null $length
mixed $replacement

Returns

\Pop\Db\Record\Collection

sort()

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

Sort items

Parameters

callable|null $callback
integer $flags

Returns

\Pop\Db\Record\Collection

sortByAsc()

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

Sort the collection ascending

Parameters

integer $flags

Returns

\Pop\Db\Record\Collection

sortByDesc()

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

Sort the collection descending

Parameters

integer $flags

Returns

\Pop\Db\Record\Collection

getItems()

getItems() : array

Method to get collection object items

Returns

array

toArray()

toArray() : array

Method to get collection object as an array

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->items[$name]

Parameters

string $name
mixed $value

__get()

__get(string  $name) : mixed

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

Parameters

string $name

Returns

mixed

__isset()

__isset(string  $name) : boolean

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

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $name) : void

Magic method to unset $this->items[$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

getItemsAsArray()

getItemsAsArray(mixed  $items) : array

Method to get items as an array

Parameters

mixed $items

Returns

array