Passed
Pull Request — master (#1111)
by Aleksei
10:58
created

PipelineBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Interceptors;
6
7
use Spiral\Interceptors\Handler\InterceptorPipeline;
8
9
/**
10
 * Accepts only {@see InterceptorInterface} instances to build a pipeline.
11
 */
12
class PipelineBuilder implements PipelineBuilderInterface
13
{
14
    private InterceptorPipeline $pipeline;
15
16 3
    public function __construct()
17
    {
18 3
        $this->pipeline = new InterceptorPipeline();
19
    }
20
21 2
    public function withInterceptors(InterceptorInterface ...$interceptors): static
22
    {
23 2
        $clone = clone $this;
24 2
        $clone->pipeline = $this->pipeline->withInterceptors(...$interceptors);
25 2
        return $clone;
26
    }
27
28 2
    public function build(HandlerInterface $last): HandlerInterface
29
    {
30 2
        return $this->pipeline->withHandler($last);
31
    }
32
}
33