2017 © Pedro Peláez
 

library pipe

Pipeline pattern simple implementation

image

ztsu/pipe

Pipeline pattern simple implementation

  • Monday, December 18, 2017
  • by ztsu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 885 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

ztsu/pipe

Provides a simple implemenation of a pipeline pattern., (*1)

Requirements

Supports PHP starting with version 5.4., (*2)

Installation

composer require ztsu/pipe

Usage

Here is a basic usage example:, (*3)


use Ztsu\Pipe\Pipeline; $a = function ($payload, $next) { return $next($payload . "a"); }; $b = function ($payload, $next) { return $next($payload . "b"); }; $pipeline = new Pipeline; $pipeline->add($a); $pipeline->add($b); echo $pipeline->run(""); // "ab"

Here $a and $b are callables with two arguments. First is for accumulating a payload from previous stages. Second is for continuing next stages in a pipeline., (*4)

For break pipeline just return $payload instead of call $next:, (*5)

$pipeline = new Pipeline;

$break = function ($payload, $next) {
    return $payload;
};

$pipeline->add($a);
$pipeline->add($break);
$pipeline->add($b);

echo $pipeline(""); // "a"

A pipeline is callable too. And it's able to use as a stage., (*6)

For this just add it to another pipeline:, (*7)

$pipeline = new Pipeline;

$pipeline->add($a);
$pipeline->add($bc);

echo $pipeline(""); // "abc"

If use pipeline with a break as a stage it breaks entire pipeline., (*8)

License

MIT., (*9)

The Versions

18/12 2017

dev-master

9999999-dev

Pipeline pattern simple implementation

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Alexey Golovnya

02/08 2016

0.1.1

0.1.1.0

Pipeline pattern simple implementation

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Alexey Golovnya

02/08 2016

1.0.0

1.0.0.0

Pipeline pattern simple implementation

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Alexey Golovnya

21/04 2016

0.1.0

0.1.0.0

Pipeline pattern simple implementation

  Sources   Download

MIT

The Development Requires

by Alexey Golovnya