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

PipelineBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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