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

PipelineBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A withInterceptors() 0 5 1
A build() 0 3 1
A __construct() 0 3 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