antograssiot 58784a5276 fix CS 11 years ago
..
Iterator 58784a5276 fix CS 11 years ago
Collection.php edefed1be5 Extracting collection definition into an interface 11 years ago
CollectionInterface.php 0e4cc2396d Adding a ResultSetInterface to standarize the result of a query 11 years ago
CollectionTrait.php edefed1be5 Extracting collection definition into an interface 11 years ago
ExtractTrait.php 608e1c5ae7 Add space after closures' function keyword 11 years ago
README.md f7af8b706c Added markdown link instead of using plain url in Collection readme 11 years ago
composer.json 3c41eb734d Extracting the collection function into a new file inside Collection 11 years ago
functions.php c1e03c44fa Adding missing use statement 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