sparhandy/pipeandfilter
最新稳定版本:1.0.1.1
Composer 安装命令:
composer require sparhandy/pipeandfilter
包简介
Pipe and Filter Architecture
README 文档
README
PipeAndFilter
This repository contains all necessary files to use the Pipe & Filter Architecture in PHP.
Installation with composer
composer require "sparhandy/pipeandfilter"
Usage
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. ?>
Filter
<?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']; } } } ?>
How to contribute
If you want to contribute to the standard here is how it works.
- Create a fork of Sparhandy/PipeAndFilter.
- Create your branch from master and commit your changes.
- Push your branch to your fork.
- Create a pull request on GitHub.
- Discuss your pull request with us.
- Our devs will then merge or close the pull request.
统计信息
- 总下载量: 14.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-12-12