Creates a filtered iterator from another iterator. The filtering is done by passing a callback function to each of the elements and taking them out if it does not return true.
- IteratorIterator implements Iterator, Traversable, OuterIterator
- Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
callableThe callback used to filter the elements in this collection
__construct() public ¶
__construct( Iterator $items , callable $callback )
Creates a filtered iterator using the callback to determine which items are accepted or rejected.
Each time the callback is executed it will receive the value of the element in the current iteration, the key of the element and the passed $items iterator as arguments, in that order.
- Iterator $items
- The items to be filtered.
- callable $callback
If passed incorrect type for items.
Methods inherited from Cake\Collection\Collection
__debugInfo() public ¶
Returns an array that can be used to describe the internal state of this object.
Throws an exception.
Issuing a count on a Collection can have many side effects, some making the Collection unusable after the count operation.
serialize() public ¶
Returns a string representation of this object that can be used to reconstruct it
Methods used from Cake\Collection\CollectionTrait
cartesianProduct() public ¶
cartesianProduct( callable $operation = null , callable $filter = null )
listNested() public ¶
listNested( $dir = 'desc' , $nestingKey = 'children' )
optimizeUnwrap() protected ¶
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out