sergiors/pipeline
Composer 安装命令:
composer require sergiors/pipeline
包简介
Compose sequence of operations, immutable without side-effects
README 文档
README
Install
composer require sergiors/pipeline
How to use
use Sergiors\Pipeline\Pipeline; $pipeline = (new Pipeline) ->pipe(function ($payload) { return $payload + 2; }) ->pipe(function ($payload) { return $payload * 2; }); echo $pipeline(10); // => 24 // echo $pipeline->process(10);
$pipeline = (new Pipeline) ->pipe(function ($payload, $container) { ... }) ->pipe(function ($payload, $container) { ... }); $container = ...; $pipeline(10, $container);
You can use Sergiors\Pipeline\Reduce, Sergiors\Pipeline\Filter and Sergiors\Pipeline\Map to compose the pipeline more readable.
use Sergiors\Pipeline\Pipeline; use Sergiors\Pipeline\Filter; $getOrgs = (new Pipeline) ->pipe(new Filter(function ($org) { return $org instanceof OrgInterface; })); // an array with OrgInterface and UserInterface objects $users = [...]; print_r($getOrgs($users));
Motivation
License
MIT
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-28