Trait CollectionTrait
Offers a handful of method to manipulate iterators
- Cake\Collection\CollectionTrait uses Cake\Collection\ExtractTrait
Direct Users
- Cake\Collection\Collection
- Cake\Collection\Iterator\TreeIterator
- Cake\Collection\Iterator\TreePrinter
- Cake\Collection\Iterator\ZipIterator
- Cake\ORM\ResultSet
Indirect Users
- Cake\Collection\Iterator\BufferedIterator
- Cake\Collection\Iterator\ExtractIterator
- Cake\Collection\Iterator\FilterIterator
- Cake\Collection\Iterator\InsertIterator
- Cake\Collection\Iterator\NestIterator
- Cake\Collection\Iterator\NoChildrenIterator
- Cake\Collection\Iterator\ReplaceIterator
- Cake\Collection\Iterator\SortIterator
- Cake\Datasource\ResultSetDecorator
Method Summary
- _unwrap() public
- append() public
- appendItem() public
- avg() public
- buffered() public
- cartesianProduct() public
- chunk() public
- chunkWithKeys() public
- combine() public
- compile() public
- contains() public
- count() public
- countBy() public
- countKeys() public
- each() public
- every() public
- extract() public
- filter() public
- first() public
- firstMatch() public
- groupBy() public
- indexBy() public
- insert() public
- isEmpty() public
- jsonSerialize() public
- last() public
- lazy() public
- listNested() public
- map() public
- match() public
- max() public
- median() public
- min() public
- nest() public
- optimizeUnwrap() protected
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
- prepend() public
- prependItem() public
- reduce() public
- reject() public
- sample() public
- shuffle() public
- skip() public
- some() public
- sortBy() public
- stopWhen() public
- sumOf() public
- take() public
- takeLast() public
- through() public
- toArray() public
- toList() public
- transpose() public
- unfold() public
- unwrap() public
- zip() public
- zipWith() public
Method Detail
_unwrap()source public
_unwrap( )
append()source public
append( $items )
appendItem()source public
appendItem( $item , $key = null )
avg()source public
avg( $matcher = null )
cartesianProduct()source public
cartesianProduct( callable $operation = null , callable $filter = null )
Parameters
- callable
$operation
optional null - Operation
- callable
$filter
optional null - Filter
Returns
Cake\Collection\CollectionInterface
Throws
LogicExceptionchunk()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 )
first()source public
first( )
firstMatch()source public
firstMatch( array $conditions )
groupBy()source public
groupBy( $callback )
indexBy()source public
indexBy( $callback )
isEmpty()source public
isEmpty( )
jsonSerialize()source public
jsonSerialize( )
last()source public
last( )
lazy()source public
lazy( )
listNested()source public
listNested( $dir = 'desc' , $nestingKey = 'children' )
Returns
Cake\Collection\Iterator\TreeIterator
match()source public
match( array $conditions )
max()source public
max( $callback , $type = \SORT_NUMERIC )
median()source public
median( $matcher = null )
min()source public
min( $callback , $type = \SORT_NUMERIC )
nest()source public
nest( $idPath , $parentPath , $nestingKey = 'children' )
optimizeUnwrap()source protected
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Traversable|arrayprepend()source public
prepend( $items )
prependItem()source public
prependItem( $item , $key = null )
reduce()source public
reduce( callable $c , $zero = null )
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 )
sumOf()source public
sumOf( $matcher = null )
take()source public
take( $size = 1 , $from = 0 )
takeLast()source public
takeLast( $howMany )
through()source public
through( callable $handler )
toArray()source public
toArray( $preserveKeys = true )
toList()source public
toList( )
transpose()source public
transpose( )
Returns
Cake\Collection\CollectionInterface
Throws
LogicExceptionunfold()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–present 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.7/class-Cake.Collection.CollectionTrait.html