Collection

Collection

Collection is a library aimed at providing you easy tools to handle your PHP arrays.

Installation

Just add chindit/collection to your composer.json

composer require chindit/collection

Usage

To initiate a collection, just call the constructor with your array as parameter

$myCollection = new Chindit\Collection(['a', 'b' => 'c']);

Methods

Examples

// Let's assume we have some Car objects
$myObject = new Car();

$myCollection = new Collection($arrayOfCarObjects);

// «pluck» will access «brand» property or «getBrand» method on all elements of the collection and return its value
// «unique» will remove all duplicates
$uniqueBrands = $myCollection->pluck('brand')->unique();

Support & Contact

If you have any issue or question with this repository, do not hesitate to leave a comment in the «Issue» sections ^^