Passed
Pull Request — master (#59)
by
unknown
24:02
created

PipelineBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
c 3
b 0
f 0
wmc 3

3 Methods

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