Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cakephp/collection
[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp
https://github.com/cakephp/collection
Last synced: 3 days ago
JSON representation
[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp
- Host: GitHub
- URL: https://github.com/cakephp/collection
- Owner: cakephp
- License: other
- Created: 2014-08-24T15:20:43.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-11T02:54:57.000Z (6 months ago)
- Last Synced: 2024-05-15T13:26:04.772Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 446 KB
- Stars: 87
- Watchers: 30
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-php - CakePHP Collection - A simple collections library. (Table of Contents / Data Structure and Storage)
- awesome-php-cn - CakePHP Collection - 一个简单的集合库. (目录 / 数据结构和存储 Data Structure and Storage)
- awesome-projects - CakePHP Collection - A simple collections library. (PHP / Data Structure and Storage)
- awesome-php - CakePHP Collection - A simple collections library. (Table of Contents / Data Structure and Storage)
README
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/collection.svg?style=flat-square)](https://packagist.org/packages/cakephp/collection)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)# 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:
```php
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](https://book.cakephp.org/4/en/core-libraries/collections.html)