solution10 / pipeline
Pipeline library with named steps and ordering.
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^2.7
This package is not auto-updated.
Last update: 2024-11-10 02:29:52 UTC
README
A simple pipeline library that allows you to string together chains of tasks to perform in a given order.
This library, unlike others, allows you to name and insert steps in different orders to when they're defined.
Usage
The most simple pipeline is just a sequence of steps where the output is handed to the next step and eventually returned out of the bottom:
<?php use Solution10\Pipeline\Pipeline; $w = (new Pipeline()) ->step('double', function ($input) { return $input * 2; }) ->step('add-one', function ($input) { return $input + 1; }) ->step('stringify', function ($input) { return 'Result: '.$input; }) ; $result = $w->run(2); // $result is "Result: 5"
Each step is given a name as the first parameter and a callable
as it's second.
Pipeline::run()
is then called with the input to generate the output.
There are various types of run()
you can do, as well as variety of ways of defining steps, see the
Userguide for more details.
PHP Requirements
- PHP >= 5.6 || HHVM >= 3.3