Pipeline   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 3 1
A process() 0 3 1
A pipe() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace League\Pipeline;
5
6
class Pipeline implements PipelineInterface
7
{
8
    /**
9
     * @var callable[]
10
     */
11
    private $stages = [];
12
13
    /**
14
     * @var ProcessorInterface
15
     */
16
    private $processor;
17
18 14
    public function __construct(ProcessorInterface $processor = null, callable ...$stages)
19
    {
20 14
        $this->processor = $processor ?? new FingersCrossedProcessor;
21 14
        $this->stages = $stages;
22 14
    }
23
24 8
    public function pipe(callable $stage): PipelineInterface
25
    {
26 8
        $pipeline = clone $this;
27 8
        $pipeline->stages[] = $stage;
28
29 8
        return $pipeline;
30
    }
31
32 10
    public function process($payload)
33
    {
34 10
        return $this->processor->process($payload, ...$this->stages);
35
    }
36
37 4
    public function __invoke($payload)
38
    {
39 4
        return $this->process($payload);
40
    }
41
}
42