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 = [];
* Constructor.
*
* @param callable[] $stages
* @throws InvalidArgumentException
public function __construct(array $stages = [])
foreach ($stages as $stage) {
if (false === is_callable($stage)) {
throw new InvalidArgumentException('All stages should be callable.');
}
$this->stages = $stages;
* @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)
foreach ($this->stages as $stage) {
$payload = call_user_func($stage, $payload);
return $payload;
public function __invoke($payload)
return $this->process($payload);