runner/pipeline

v0.1.0 2018-12-28 08:14 UTC

This package is auto-updated.

Last update: 2024-03-29 03:44:55 UTC


README

Pipeline Like Laravel

68747470733a2f2f7472617669732d63692e6f72672f52756e6e65724c65652f706970656c696e652e7376673f6272616e63683d6d6173746572 68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e6e65724c65652f706970656c696e652f6261646765732f636f7665726167652e706e673f623d6d6173746572 68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f52756e6e65724c65652f706970656c696e652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572 StyleCI 68747470733a2f2f706f7365722e707567782e6f72672f72756e6e65722f706970656c696e652f762f737461626c65 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e312d3838393242462e737667 68747470733a2f2f706f7365722e707567782e6f72672f72756e6e65722f706970656c696e652f6c6963656e7365

Usage

<?php

use Runner\Pipeline\Pipeline;

$pipeline = new Pipeline();

$a = function ($payload, $next) {
    echo 'a' . PHP_EOL;
    return $next($payload);
};
$b = function ($payload, $next) {
    echo 'b' . PHP_EOL;
    return $next($payload);
};
$c = new class{
    public function handle($payload, $next)
    {
        echo 'c' . PHP_EOL;
        return $next($payload);
    }
};

$pipeline->pipe($a)->pipe($b)->pipe($c)->method('handle')->payload(1)->process(function ($payload) {
    return $payload * 20;
});