Browse Source

Merge pull request #4375 from cakephp/3.0-collection-subtree

3.0 collection subtree
José Lorenzo Rodríguez 11 years ago
parent
commit
1951b16d31
3 changed files with 45 additions and 0 deletions
  1. 3 0
      composer.json
  2. 30 0
      src/Collection/README.md
  3. 12 0
      src/Collection/composer.json

+ 3 - 0
composer.json

@@ -38,5 +38,8 @@
 		"psr-4": {
 			"Cake\\Test\\": "tests"
 		}
+	},
+	"replace": {
+		"cakephp/collection": "self.version"
 	}
 }

+ 30 - 0
src/Collection/README.md

@@ -0,0 +1,30 @@
+# 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](http://book.cakephp.org/3.0/en/core-libraries/collections.html)
+
+

+ 12 - 0
src/Collection/composer.json

@@ -0,0 +1,12 @@
+{
+    "name": "cakephp/collection",
+    "description": "Work easily with arrays and iterators by having a battery of utility traversal methods",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "CakePHP Community",
+            "homepage": "http://cakephp.org"
+        }
+    ],
+    "minimum-stability": "beta"
+}