enzyme/集合

一个包含所有数组的数组管理器。

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

This package is not auto-updated.

Last update: 2024-09-14 19:04:08 UTC


README

Build Status Coverage Status Scrutinizer Code Quality StyleCI

一个包含所有数组的数组管理器。

安装

$ composer require enzyme/collection

用法

您可以从标准的PHP数组创建一个集合。一旦有了集合,您就可以使用它公开的所有方法。

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);
});

该集合实现了ArrayAccessIteratorCountable,因此您可以用它作为标准数组。

use Enzyme\Collection\Collection;

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

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

在上面的例子中,等效且更易读的方法将是$collection->first()

可用方法

贡献

请参阅CONTRIBUTING.md

许可

MIT - 版权(c)2016 Tristan Strathearn,见LICENSE