sparhandy / pipeandfilter
Pipe and Filter Architecture
Installs: 13 563
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 10
Forks: 0
Open Issues: 0
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: 2025-03-12 11:36:49 UTC
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.