Koji Tanaka fe1d812c89 Update URL in *.md, *.json 9 years ago
..
Iterator 1c4c0ffac9 Fix up late static binding newable. 9 years ago
Collection.php 72f5332146 Make all doc block classes FQCN as per CS. 10 years ago
CollectionInterface.php 9fff233e7d Merge branch 'master' into 3.next 9 years ago
CollectionTrait.php 8258072329 Merge branch 'master' into 3.next 9 years ago
ExtractTrait.php 855c4d114b Fix CS error. 9 years ago
LICENSE.txt 684b4db392 Adds license file and badges for Collection subtree split 10 years ago
README.md fe1d812c89 Update URL in *.md, *.json 9 years ago
composer.json fe1d812c89 Update URL in *.md, *.json 9 years ago
functions.php 5f51f3aa09 Fix CS warnings in function docblocks 11 years ago

README.md

Total Downloads License

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