enzyme/collection

An all encompassing array manager.

v1.0.0 2016-10-11 23:17 UTC

This package is not auto-updated.

Last update: 2024-12-07 20:06:39 UTC


README

Build Status Coverage Status Scrutinizer Code Quality StyleCI

An all encompassing array manager.

Installation

$ composer require enzyme/collection

Usage

You can create a collection from a standard PHP array. Once you have a collection, you can make use of all the methods it exposes.

use Acme\Mailer;
use Enzyme\Collection\Collection;

$users = new Collection(['John123', 'Jane456', 'Harry789']);

// Send each user an email.
$users->each(function ($user) {
    Mailer::sendWelcomeEmail($user);
});

The collection implements ArrayAccess, Iterator and Countable, so you can use it as a standard array.

use Enzyme\Collection\Collection;

$users = new Collection(['John123', 'Jane456', 'Harry789']);

var_dump($users[0]); // 'John123'

In the example above, the equivalent and much more readable method would be $collection->first().

Available methods

Contributing

Please see CONTRIBUTING.md

License

MIT - Copyright (c) 2016 Tristan Strathearn, see LICENSE