Class FilterIterator
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
- Cake\Collection\Iterator\FilterIterator
Method Detail
__constructsource 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.
Parameters
- Iterator
$items
- The items to be filtered.
- callable
$callback
- Callback.
Throws
InvalidArgumentException
If passed incorrect type for items.
Overrides
Cake\Collection\Collection::__construct()
Methods inherited from Cake\Collection\Collection
__debugInfosource public
__debugInfo( )
Returns an array that can be used to describe the internal state of this object.
Returns
array
array
countsource public
count( )
Throws an exception.
Issuing a count on a Collection can have many side effects, some making the Collection unusable after the count operation.
Throws
LogicException
\LogicException
serializesource public
serialize( )
Returns a string representation of this object that can be used to reconstruct it
Returns
string
string
Implementation of
Serializable::serialize()
unserializesource public
unserialize( string $collection )
Unserializes the passed string and rebuilds the Collection instance
Parameters
- string
$collection
- The serialized collection
Implementation of
Serializable::unserialize()
Methods used from Cake\Collection\CollectionTrait
_unwrapsource public
_unwrap( )
Backwards compatible wrapper for unwrap()
Deprecated
Returns
Iterator
\Iterator
appendsource public
append( mixed $items )
Implementation of
Cake\Collection\CollectionInterface::append()
bufferedsource public
buffered( )
Returns
Cake\Collection\Iterator\BufferedIterator
\Cake\Collection\Iterator\BufferedIterator
Implementation of
Cake\Collection\CollectionInterface::buffered()
chunksource public
chunk( mixed $chunkSize )
Implementation of
Cake\Collection\CollectionInterface::chunk()
combinesource public
combine( mixed $keyPath , mixed $valuePath , mixed $groupPath null )
Implementation of
Cake\Collection\CollectionInterface::combine()
compilesource public
compile( mixed $preserveKeys true )
Implementation of
Cake\Collection\CollectionInterface::compile()
containssource public
contains( mixed $value )
Implementation of
Cake\Collection\CollectionInterface::contains()
countBysource public
countBy( mixed $callback )
Implementation of
Cake\Collection\CollectionInterface::countBy()
everysource public
every( callable $c )
Implementation of
Cake\Collection\CollectionInterface::every()
extractsource public
extract( mixed $matcher )
Implementation of
Cake\Collection\CollectionInterface::extract()
filtersource public
filter( callable $c null )
Returns
Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator
Implementation of
Cake\Collection\CollectionInterface::filter()
firstMatchsource public
firstMatch( array $conditions )
Implementation of
Cake\Collection\CollectionInterface::firstMatch()
groupBysource public
groupBy( mixed $callback )
Implementation of
Cake\Collection\CollectionInterface::groupBy()
indexBysource public
indexBy( mixed $callback )
Implementation of
Cake\Collection\CollectionInterface::indexBy()
insertsource public
insert( mixed $path , mixed $values )
Returns
Cake\Collection\Iterator\InsertIterator
\Cake\Collection\Iterator\InsertIterator
Implementation of
Cake\Collection\CollectionInterface::insert()
jsonSerializesource public
jsonSerialize( )
Implementation of
Cake\Collection\CollectionInterface::jsonSerialize()
listNestedsource public
listNested( mixed $dir 'desc' , mixed $nestingKey 'children' )
Returns
Cake\Collection\Iterator\TreeIterator
\Cake\Collection\Iterator\TreeIterator
Implementation of
Cake\Collection\CollectionInterface::listNested()
mapsource public
map( callable $c )
Returns
Cake\Collection\Iterator\ReplaceIterator
\Cake\Collection\Iterator\ReplaceIterator
Implementation of
Cake\Collection\CollectionInterface::map()
matchsource public
match( array $conditions )
Implementation of
Cake\Collection\CollectionInterface::match()
maxsource public
max( mixed $callback , mixed $type SORT_NUMERIC )
Implementation of
Cake\Collection\CollectionInterface::max()
minsource public
min( mixed $callback , mixed $type SORT_NUMERIC )
Implementation of
Cake\Collection\CollectionInterface::min()
nestsource public
nest( mixed $idPath , mixed $parentPath )
Implementation of
Cake\Collection\CollectionInterface::nest()
reducesource public
reduce( callable $c , mixed $zero null )
Implementation of
Cake\Collection\CollectionInterface::reduce()
rejectsource public
reject( callable $c )
Returns
Cake\Collection\Iterator\FilterIterator
\Cake\Collection\Iterator\FilterIterator
Implementation of
Cake\Collection\CollectionInterface::reject()
samplesource public
sample( mixed $size 10 )
Implementation of
Cake\Collection\CollectionInterface::sample()
skipsource public
skip( mixed $howMany )
Implementation of
Cake\Collection\CollectionInterface::skip()
sortBysource public
sortBy( mixed $callback , mixed $dir SORT_DESC , mixed $type SORT_NUMERIC )
Implementation of
Cake\Collection\CollectionInterface::sortBy()
stopWhensource public
stopWhen( mixed $condition )
Returns
Cake\Collection\Iterator\StoppableIterator
\Cake\Collection\Iterator\StoppableIterator
Implementation of
Cake\Collection\CollectionInterface::stopWhen()
sumOfsource public
sumOf( mixed $matcher null )
Implementation of
Cake\Collection\CollectionInterface::sumOf()
takesource public
take( mixed $size 1 , mixed $from 0 )
Implementation of
Cake\Collection\CollectionInterface::take()
throughsource public
through( callable $handler )
Implementation of
Cake\Collection\CollectionInterface::through()
toArraysource public
toArray( mixed $preserveKeys true )
Implementation of
Cake\Collection\CollectionInterface::toArray()
unfoldsource public
unfold( callable $transformer null )
Implementation of
Cake\Collection\CollectionInterface::unfold()
zipWithsource public
zipWith( mixed $items , mixed $callable )
Implementation of
Cake\Collection\CollectionInterface::zipWith()
Methods used from Cake\Collection\ExtractTrait
_createMatcherFiltersource protected
_createMatcherFilter( array $conditions )
Returns a callable that receives a value and will return whether or not it matches certain condition.
Parameters
- array
$conditions
- A key-value list of conditions to match where the key is the property path to get from the current item and the value is the value to be compared the item with.
Returns
callable
callable
_extractsource protected
_extract( array|ArrayAccess $data , array $path )
Returns a column from $data that can be extracted by iterating over the column names contained in $path. It will return arrays for elements in represented with {*}
Parameters
- array|ArrayAccess
$data
- Data.
- array
$path
- Path to extract from.
Returns
mixed
mixed
_propertyExtractorsource protected
_propertyExtractor( string|callable $callback )
Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.
Parameters
- string|callable
$callback
- A dot separated path of column to follow so that the final one can be returned or a callable that will take care of doing that.
Returns
callable
callable
_simpleExtractsource protected
_simpleExtract( array|ArrayAccess $data , array $path )
Returns a column from $data that can be extracted by iterating over the column names contained in $path
Parameters
- array|ArrayAccess
$data
- Data.
- array
$path
- Path to extract from.
Returns
mixed
mixed
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Collection.Iterator.FilterIterator.html