solution10/pipeline

Pipeline library with named steps and ordering.

v1.2.0 2017-05-07 11:05 UTC

This package is not auto-updated.

Last update: 2024-12-22 02:58:10 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.

Build Status Latest Stable Version Total Downloads License

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

Author

Alex Gisby: GitHub, Twitter

License

MIT