pangolinkeys / pipe
提供标准化管道模式的软件包
v2.0.0
2019-02-25 13:11 UTC
Requires (Dev)
- phpunit/phpunit: ^7.3
README
存储库提供PHP中管道模式的简单实现。
要使用实现 Pipeline
特性。从你的类中调用 ->pipe()
,传递一个实现 ProvidesPipeline
类的对象列表。可选地使用 InitializePipeline
辅助类将值输入到管道中。
请参阅 tests
文件夹中的 Example
文件夹中的示例。
return $this->pipe(
new InitializePipeline($value),
new DivideByTwo,
new DivideByTwo,
new TimesByOneThousand,
new TimesByOneThousand
);
Composer
要将此软件包安装到您的composer项目中,请运行
composer require pangolinkeys/pipe
上下文管道
您可以选择实现 ProvidesContextPipeline
以在管道中传递管道对象的实例。这将成为 handle
方法的第二个参数。
按类名管道
从v2版本开始,您可以通过类名引用定义管道,并允许管道处理类实例化。
return $this->pipe(
new InitializePipeline($value),
DivideByTwo::class,
TimesByOneThousand::class
);