sparhandy / pipeandfilter
管道与过滤器架构
1.0.1.1
2018-01-08 12:11 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: 4.8.*
- sparhandy/codingstandard: ^1.0
This package is not auto-updated.
Last update: 2024-09-25 09:22:53 UTC
README
PipeAndFilter
此仓库包含使用PHP中的管道与过滤器架构所需的所有文件。
使用composer安装
composer require "sparhandy/pipeandfilter"
使用方法
PipeFactory
<?php // Implements \Sparhandy\PipeAndFilter\FilterInterface $exampleFilterFoo = new Acme\Filter\Foo(); $exampleFilterBar = new Acme\Filter\Bar(); $exampleFilterBaz = new Acme\Filter\Baz(); $filters = [ $exampleFilterFoo, $exampleFilterBar, $exampleFilterBaz, ]; $factory = new \Sparhandy\PipeAndFilter\PipeFactory(); $pipe = $factory->build($filters); // The variable, to be processed by the $filters $context = []; // The context, to be processed by the $filters $someParameter = [ 'foo' => 'bar', ]; $pipe->run($context, $someParameter); // $context is now modified by your filters. ?>
过滤器
<?php class FooFilter implements Sparhandy\PipeAndFilter\FilterInterface { /** * @param mixed $context * @param mixed[] $someParameter * * @return void */ public function execute(&$context, array $someParameter) { if (isset($context['foo'])) { $context['bar'] = $someParameter['baz']; } } } ?>
如何贡献
如果您想为此标准贡献,以下是操作步骤。
- 从Sparhandy/PipeAndFilter创建一个分支。
- 从master创建您的分支并提交更改。
- 将您的分支推送到您的分支。
- 在GitHub上创建一个pull request。
- 与我们就pull request进行讨论。
- 然后我们的开发人员将合并或关闭pull request。