2017 © Pedro PelĂĄez
 

library bdf-pipeline

Bdf Pipeline component

image

b2pweb/bdf-pipeline

Bdf Pipeline component

  • Friday, June 1, 2018
  • by Johnmeurt
  • Repository
  • 1 Watchers
  • 1 Stars
  • 553 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 49 % Grown

The README.md

B2PWeb Pipeline

A PHP Pipeline pattern., (*1)

Build Status Scrutinizer Code Quality Packagist Version Total Downloads, (*2)

Install via composer

$ composer require b2pweb/bdf-pipeline

Usage Instructions

A basic and classic use of pipeline with a pipe processor., (*3)

use Bdf\Pipeline\Pipeline;
use Bdf\Pipeline\CallableFactory\LinkedCallableFactory;

$pipeline = new Pipeline(new LinkedCallableFactory());
$pipeline->pipe(function($value) {
    return $value + 2;
});

// Returns 12
$pipeline->send(10);

The pipeline lib comes with an advanced processor (used by default)., (*4)

use Bdf\Pipeline\Pipeline;
use Bdf\Pipeline\CallableFactory\StackCallableFactory;

$pipeline = new Pipeline(new StackCallableFactory());
$pipeline->pipe(function($next, $foo, $bar) {
    // Do something
    ...

    $result = $next($foo, $bar);

    // Do something else
    ...

    return $result;
});
$pipeline->outlet(function($foo, $bar) {
    return "${foo}.${bar}";
});
// Manage multiple parameters
echo $pipeline->send('foo', 'bar'); // Print foo.bar

Ok, So ?

You can use this package as a classic pipe, but it was designed to be easily extended:, (*5)

$pipeline->pipe(new LogCommand());
$pipeline->outlet(new CreateUserHandler());

...

$pipeline->prepend(new TransactionnalCommand());
$pipeline->send(new CreateUserCommand());
class TransactionnalCommand
{
    public function __invoke($next, $command)
    {
        try {
            $result = $next($command);

            // Commit and return the result
            ...
            return $result;
        } catch (\Throwable $exception) {
            // Rollback and propagate exception
            throw $exception;
        }
    }
}

The pipeline is reusable:, (*6)

$pipeline = new Pipeline();
$pipeline->pipe(new Double());

$new = clone $pipeline;

$new->pipe(new Double());

echo $pipeline->send(2); // 4
echo $new->send(2); // 8

License

Distributed under the terms of the MIT license., (*7)

The Versions

01/06 2018

dev-master

9999999-dev

Bdf Pipeline component

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Tanneux

pattern pipeline design pattern

22/03 2018

v1.1.1

1.1.1.0

Bdf Pipeline component

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Sébastien Tanneux

pattern pipeline design pattern

19/03 2018

v1.1.0

1.1.0.0

Bdf Pipeline component

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Sébastien Tanneux

pattern pipeline design pattern

28/02 2018

v1.0.0

1.0.0.0

Bdf Pipeline component

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Tanneux

pattern pipeline design pattern