Offers a handful of methods to manipulate iterators
Returns a callable that receives a value and will return whether or not it matches certain condition.
Returns a column from $data that can be extracted by iterating over the column names contained in $path.
Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path.
Returns a column from $data that can be extracted by iterating over the column names contained in $path
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
_createMatcherFilter(array $conditions)
Returns a callable that receives a value and will return whether or not it matches certain condition.
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.
\Closure
_extract(mixed $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 {*}
array|\ArrayAccess
$data Data.
string[]
$path Path to extract from.
mixed
_propertyExtractor(mixed $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.
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.
callable
_simpleExtract(mixed $data, array $path)
Returns a column from $data that can be extracted by iterating over the column names contained in $path
array|\ArrayAccess
$data Data.
string[]
$path Path to extract from.
mixed
append(mixed $items)
mixed
$items appendItem(mixed $item, mixed $key)
mixed
$item mixed
$key optional avg(mixed $path)
mixed
$path optional buffered()
cartesianProduct(?callable $operation, ?callable $filter)
{@inheritDoc}
callable|null
$operation optional A callable that allows you to customize the product result.
callable|null
$filter optional A filtering callback that must return true for a result to be part of the final results.
\Cake\Collection\CollectionInterface
LogicException
chunk(int $chunkSize)
int
$chunkSize chunkWithKeys(int $chunkSize, bool $preserveKeys)
int
$chunkSize bool
$preserveKeys optional combine(mixed $keyPath, mixed $valuePath, mixed $groupPath)
mixed
$keyPath mixed
$valuePath mixed
$groupPath optional compile(bool $preserveKeys)
bool
$preserveKeys optional contains(mixed $value)
mixed
$value count()
countBy(mixed $callback)
mixed
$callback countKeys()
each(callable $callback)
callable
$callback every(callable $callback)
callable
$callback extract(mixed $path)
mixed
$path filter(?callable $callback)
?callable
$callback optional first()
firstMatch(array $conditions)
array
$conditions groupBy(mixed $callback)
mixed
$callback indexBy(mixed $callback)
mixed
$callback insert(string $path, mixed $values)
string
$path mixed
$values isEmpty()
jsonSerialize()
last()
lazy()
listNested(mixed $order, mixed $nestingKey)
mixed
$order optional mixed
$nestingKey optional map(callable $callback)
callable
$callback match(array $conditions)
array
$conditions max(mixed $callback, int $sort)
mixed
$callback int
$sort optional median(mixed $path)
mixed
$path optional min(mixed $callback, int $sort)
mixed
$callback int
$sort optional nest(mixed $idPath, mixed $parentPath, string $nestingKey)
mixed
$idPath mixed
$parentPath string
$nestingKey optional newCollection(mixed ...$args)
Returns a new collection.
Allows classes which use this trait to determine their own type of returned collection interface
mixed
...$args Constructor arguments.
\Cake\Collection\CollectionInterface
optimizeUnwrap()
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
iterable
prepend(mixed $items)
mixed
$items prependItem(mixed $item, mixed $key)
mixed
$item mixed
$key optional reduce(callable $callback, mixed $initial)
callable
$callback mixed
$initial optional reject(callable $callback)
callable
$callback sample(int $length)
int
$length optional shuffle()
skip(int $length)
int
$length some(callable $callback)
callable
$callback sortBy(mixed $callback, int $order, int $sort)
mixed
$callback int
$order optional int
$sort optional stopWhen(mixed $condition)
mixed
$condition sumOf(mixed $path)
mixed
$path optional take(int $length, int $offset)
int
$length optional int
$offset optional takeLast(int $length)
int
$length through(callable $callback)
callable
$callback toArray(bool $preserveKeys)
bool
$preserveKeys optional toList()
transpose()
{@inheritDoc}
\Cake\Collection\CollectionInterface
LogicException
unfold(?callable $callback)
?callable
$callback optional unwrap()
zip(iterable $items)
iterable
$items zipWith(iterable $items, mixed $callback)
iterable
$items mixed
$callback
© 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/4.1/trait-Cake.Collection.CollectionTrait.html