| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 10 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class Pipeline implements PipelineInterface |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var callable[] |
||
| 10 | */ |
||
| 11 | private array $stages; |
||
| 12 | private ProcessorInterface $processor; |
||
| 13 | |||
| 14 | public function __construct(?ProcessorInterface $processor = null, callable ...$stages) |
||
| 18 | 14 | } |
|
| 19 | |||
| 20 | 14 | public function pipe(callable $operation): PipelineInterface |
|
| 21 | 14 | { |
|
| 22 | 14 | $pipeline = clone $this; |
|
| 23 | $pipeline->stages[] = $operation; |
||
| 24 | 8 | ||
| 25 | return $pipeline; |
||
| 26 | 8 | } |
|
| 27 | 8 | ||
| 28 | public function process($payload) |
||
| 29 | 8 | { |
|
| 30 | return $this->processor->process($payload, ...$this->stages); |
||
| 31 | } |
||
| 32 | 10 | ||
| 33 | public function __invoke($payload) |
||
| 36 | } |
||
| 37 | } |
||
| 38 |