Jose Lorenzo Rodriguez a5a22bd7a3 A different fix for #7649 10 years ago
..
Iterator 673a5175f1 Fix scrutinizer warnings in several packages. 10 years ago
Collection.php c96f30ce7f Issuing a count() on a Collection should throw an exception 10 years ago
CollectionInterface.php 4075c3d934 typo in API docs example 10 years ago
CollectionTrait.php a5a22bd7a3 A different fix for #7649 10 years ago
ExtractTrait.php 7d157b60a2 Fix CS. 10 years ago
README.md 0a1b1a123a Correct CS in readme 11 years ago
composer.json 4a0955dbcc Convert indentation to spaces for composer.json files 11 years ago
functions.php 5f51f3aa09 Fix CS warnings in function docblocks 11 years ago

README.md

CakePHP Collection Library

The collection classes provide a set of tools to manipulate arrays or Traversable objects. If you have ever used underscore.js, you have an idea of what you can expect from the collection classes.

Usage

Collections can be created using an array or Traversable object. A simple use of a Collection would be:

use Cake\Collection\Collection;

$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);

// Create a new collection containing elements
// with a value greater than one.
$overOne = $collection->filter(function ($value, $key, $iterator) {
    return $value > 1;
});

The Collection\CollectionTrait allows you to integrate collection-like features into any Traversable object you have in your application as well.

Documentation

Please make sure you check the official documentation