Properties

$_buffer

$_buffer : \SplDoublyLinkedList

The in-memory cache containing results from previous iterators

Type

\SplDoublyLinkedList

$_index

$_index : integer

Points to the next record number that should be fetched

Type

integer

$_current

$_current : mixed

Last record fetched from the inner iterator

Type

mixed

$_key

$_key : mixed

Last key obtained from the inner iterator

Type

mixed

$_started

$_started : boolean

Whether or not the internal iterator's rewind method was already called

Type

boolean

$_finished

$_finished : boolean

Whether or not the internal iterator has reached its end.

Type

boolean

Methods

__construct()

__construct(array|\Traversable  $items) 

Maintains an in-memory cache of the results yielded by the internal iterator.

Parameters

array|\Traversable $items

The items to be filtered.

serialize()

serialize() : string

Returns a string representation of this object that can be used to reconstruct it

Returns

string

unserialize()

unserialize(string  $buffer) : void

Unserializes the passed string and rebuilds the BufferedIterator instance

Parameters

string $buffer

The serialized buffer iterator

count()

count() : integer

Returns the number or items in this collection

WARNINGS:

Consumes all elements for NoRewindIterator collections:

On certain type of collections, calling this method may render unusable afterwards. That is, you may not be able to get elements out of it, or to iterate on it anymore.

Specifically any collection wrapping a Generator (a function with a yield statement) or a unbuffered database cursor will not accept any other function calls after calling count() on it.

Create a new collection with buffered() method to overcome this problem.

Can report more elements than unique keys:

Any collection constructed by appending collections together, or by having internal iterators returning duplicate keys, will report a larger amount of elements using this functions than the final amount of elements when converting the collections to a keyed array. This is because duplicate keys will be collapsed into a single one in the final array, whereas this count method is only concerned by the amount of elements after converting it to a plain list.

If you need the count of elements after taking the keys in consideration (the count of unique keys), you can call countKeys()

Will change the current position of the iterator:

Calling this method at the same time that you are iterating this collections, for example in a foreach, will result in undefined behavior. Avoid doing this.

Returns

integer

countKeys()

countKeys() : integer

{@inheritDoc}

Returns

integer

__debugInfo()

__debugInfo() : array

Returns an array that can be used to describe the internal state of this object.

Returns

array

each()

each(callable  $c) 

{@inheritDoc}

Parameters

callable $c

every()

every(callable  $c) 

{@inheritDoc}

Parameters

callable $c

some()

some(callable  $c) 

{@inheritDoc}

Parameters

callable $c

contains()

contains(  $value) 

{@inheritDoc}

Parameters

$value

reduce()

reduce(callable  $c,   $zero = null) 

{@inheritDoc}

Parameters

callable $c
$zero

extract()

extract(  $matcher) 

{@inheritDoc}

Parameters

$matcher

max()

max(  $callback,   $type = \SORT_NUMERIC) 

{@inheritDoc}

Parameters

$callback
$type

min()

min(  $callback,   $type = \SORT_NUMERIC) 

{@inheritDoc}

Parameters

$callback
$type

avg()

avg(  $matcher = null) 

{@inheritDoc}

Parameters

$matcher

median()

median(  $matcher = null) 

{@inheritDoc}

Parameters

$matcher

sortBy()

sortBy(  $callback,   $dir = \SORT_DESC,   $type = \SORT_NUMERIC) 

{@inheritDoc}

Parameters

$callback
$dir
$type

groupBy()

groupBy(  $callback) 

{@inheritDoc}

Parameters

$callback

indexBy()

indexBy(  $callback) 

{@inheritDoc}

Parameters

$callback

countBy()

countBy(  $callback) 

{@inheritDoc}

Parameters

$callback

sumOf()

sumOf(  $matcher = null) 

{@inheritDoc}

Parameters

$matcher

shuffle()

shuffle() 

{@inheritDoc}

sample()

sample(  $size = 10) 

{@inheritDoc}

Parameters

$size

take()

take(  $size = 1,   $from) 

{@inheritDoc}

Parameters

$size
$from

skip()

skip(  $howMany) 

{@inheritDoc}

Parameters

$howMany

match()

match(array  $conditions) 

{@inheritDoc}

Parameters

array $conditions

firstMatch()

firstMatch(array  $conditions) 

{@inheritDoc}

Parameters

array $conditions

first()

first() 

{@inheritDoc}

last()

last() 

{@inheritDoc}

takeLast()

takeLast(  $howMany) 

{@inheritDoc}

Parameters

$howMany

append()

append(  $items) 

{@inheritDoc}

Parameters

$items

appendItem()

appendItem(  $item,   $key = null) 

{@inheritDoc}

Parameters

$item
$key

prepend()

prepend(  $items) 

{@inheritDoc}

Parameters

$items

prependItem()

prependItem(  $item,   $key = null) 

{@inheritDoc}

Parameters

$item
$key

combine()

combine(  $keyPath,   $valuePath,   $groupPath = null) 

{@inheritDoc}

Parameters

$keyPath
$valuePath
$groupPath

nest()

nest(  $idPath,   $parentPath,   $nestingKey = 'children') 

{@inheritDoc}

Parameters

$idPath
$parentPath
$nestingKey

toArray()

toArray(  $preserveKeys = true) 

{@inheritDoc}

Parameters

$preserveKeys

toList()

toList() 

{@inheritDoc}

jsonSerialize()

jsonSerialize() 

{@inheritDoc}

compile()

compile(  $preserveKeys = true) 

{@inheritDoc}

Parameters

$preserveKeys

lazy()

lazy() 

{@inheritDoc}

listNested()

listNested(  $dir = 'desc',   $nestingKey = 'children') : \Cake\Collection\Iterator\TreeIterator

{@inheritDoc}

Parameters

$dir
$nestingKey

Returns

\Cake\Collection\Iterator\TreeIterator

unfold()

unfold(callable  $transformer = null) 

{@inheritDoc}

Parameters

callable $transformer

through()

through(callable  $handler) 

{@inheritDoc}

Parameters

callable $handler

zip()

zip(  $items) 

{@inheritDoc}

Parameters

$items

zipWith()

zipWith(  $items,   $callable) 

{@inheritDoc}

Parameters

$items
$callable

chunk()

chunk(  $chunkSize) 

{@inheritDoc}

Parameters

$chunkSize

chunkWithKeys()

chunkWithKeys(  $chunkSize,   $preserveKeys = true) 

{@inheritDoc}

Parameters

$chunkSize
$preserveKeys

isEmpty()

isEmpty() 

{@inheritDoc}

unwrap()

unwrap() 

{@inheritDoc}

_unwrap()

_unwrap() 

cartesianProduct()

cartesianProduct(callable|null  $operation = null, callable|null  $filter = null) : \Cake\Collection\CollectionInterface

Parameters

callable|null $operation

Operation

callable|null $filter

Filter

Throws

\LogicException

Returns

\Cake\Collection\CollectionInterface

key()

key() : mixed

Returns the current key in the iterator

Returns

mixed

current()

current() : mixed

Returns the current record in the iterator

Returns

mixed

rewind()

rewind() : void

Rewinds the collection

valid()

valid() : boolean

Returns whether or not the iterator has more elements

Returns

boolean

next()

next() : void

Advances the iterator pointer to the next element

optimizeUnwrap()

optimizeUnwrap() : \Traversable|array

Unwraps this iterator and returns the simplest traversable that can be used for getting the data out

Returns

\Traversable|array