承接 ztsu/pipe 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ztsu/pipe

Composer 安装命令:

composer require ztsu/pipe

包简介

Pipeline pattern simple implementation

README 文档

README

Provides a simple implemenation of a pipeline pattern.

Requirements

Supports PHP starting with version 5.4.

Installation

composer require ztsu/pipe

Usage

Here is a basic usage example:

use Ztsu\Pipe\Pipeline;

$a = function ($payload, $next) {
    return $next($payload . "a");
};

$b = function ($payload, $next) {
    return $next($payload . "b");
};

$pipeline = new Pipeline;

$pipeline->add($a);
$pipeline->add($b);

echo $pipeline->run(""); // "ab"

Here $a and $b are callables with two arguments. First is for accumulating a payload from previous stages. Second is for continuing next stages in a pipeline.

For break pipeline just return $payload instead of call $next:

$pipeline = new Pipeline;

$break = function ($payload, $next) {
    return $payload;
};

$pipeline->add($a);
$pipeline->add($break);
$pipeline->add($b);

echo $pipeline(""); // "a"

A pipeline is callable too. And it's able to use as a stage.

For this just add it to another pipeline:

$pipeline = new Pipeline;

$pipeline->add($a);
$pipeline->add($bc);

echo $pipeline(""); // "abc"

If use pipeline with a break as a stage it breaks entire pipeline.

License

MIT.

统计信息

  • 总下载量: 899
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固