enzyme / collection
An all encompassing array manager.
v1.0.0
2016-10-11 23:17 UTC
Requires
- php: >=5.5.0
Requires (Dev)
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^0.6.1
This package is not auto-updated.
Last update: 2024-12-07 20:06:39 UTC
README
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