W3cubDocs

/CakePHP 3.4

Trait CollectionTrait

Offers a handful of method to manipulate iterators

Cake\Collection\CollectionTrait uses Cake\Collection\ExtractTrait

Direct Users

Indirect Users

Method Summary

Method Detail

_unwrap()source public

_unwrap( )

append()source public

append( $items )

buffered()source public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator

cartesianProduct()source public

cartesianProduct( callable $operation null , callable $filter null )

Returns

Cake\Collection\CollectionInterface

chunk()source public

chunk( $chunkSize )

chunkWithKeys()source public

chunkWithKeys( $chunkSize , $preserveKeys true )

combine()source public

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

compile()source public

compile( $preserveKeys true )

contains()source public

contains( $value )

countBy()source public

countBy( $callback )

each()source public

each( callable $c )

every()source public

every( callable $c )

extract()source public

extract( $matcher )

filter()source public

filter( callable $c null )

Returns

Cake\Collection\Iterator\FilterIterator

first()source public

first( )

firstMatch()source public

firstMatch( array $conditions )

groupBy()source public

groupBy( $callback )

indexBy()source public

indexBy( $callback )

insert()source public

insert( $path , $values )

Returns

Cake\Collection\Iterator\InsertIterator

isEmpty()source public

isEmpty( )

jsonSerialize()source public

jsonSerialize( )

last()source public

last( )

listNested()source public

listNested( $dir 'desc' , $nestingKey 'children' )

Returns

Cake\Collection\Iterator\TreeIterator

map()source public

map( callable $c )

Returns

Cake\Collection\Iterator\ReplaceIterator

match()source public

match( array $conditions )

max()source public

max( $callback , $type SORT_NUMERIC )

min()source public

min( $callback , $type SORT_NUMERIC )

nest()source public

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

reduce()source public

reduce( callable $c , $zero null )

reject()source public

reject( callable $c )

Returns

Cake\Collection\Iterator\FilterIterator

sample()source public

sample( $size 10 )

shuffle()source public

shuffle( )

skip()source public

skip( $howMany )

some()source public

some( callable $c )

sortBy()source public

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

stopWhen()source public

stopWhen( $condition )

Returns

Cake\Collection\Iterator\StoppableIterator

sumOf()source public

sumOf( $matcher null )

take()source public

take( $size 1 , $from 0 )

through()source public

through( callable $handler )

toArray()source public

toArray( $preserveKeys true )

toList()source public

toList( )

transpose()source public

transpose( )

Returns

Cake\Collection\CollectionInterface

unfold()source public

unfold( callable $transformer null )

unwrap()source public

unwrap( )

zip()source public

zip( $items )

zipWith()source public

zipWith( $items , $callable )

Methods used from Cake\Collection\ExtractTrait

_createMatcherFilter()source 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

_extract()source 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

_propertyExtractor()source 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

_simpleExtract()source 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

© 2005–2017 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.
https://api.cakephp.org/3.4/class-Cake.Collection.CollectionTrait.html