for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace League\Pipeline;
use InvalidArgumentException;
class Pipeline implements PipelineInterface
{
/**
* @var callable[]
*/
private $stages = [];
* @var ProcessorInterface
private $processor;
* Constructor.
*
* @param callable[] $stages
* @param ProcessorInterface $processor
* @throws InvalidArgumentException
public function __construct(array $stages = [], ProcessorInterface $processor = null)
foreach ($stages as $stage) {
if (false === is_callable($stage)) {
throw new InvalidArgumentException('All stages should be callable.');
}
$this->stages = $stages;
$this->processor = $processor ?: new FingersCrossedProcessor;
* @inheritdoc
public function pipe(callable $stage)
$pipeline = clone $this;
$pipeline->stages[] = $stage;
return $pipeline;
* Process the payload.
* @param $payload
* @return mixed
public function process($payload)
return $this->processor->process($this->stages, $payload);
* Fork the pipeline
* @param callable|null $resolver
* @return Fork
public function fork(callable $resolver = null)
$fork = new Fork($this, $resolver);
return $fork;
public function __invoke($payload)
return $this->process($payload);