Test Failed
Pull Request — master (#1111)
by Aleksei
10:51
created

PipelineBuilder::withInterceptors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 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
    public function __construct()
17
    {
18
        $this->pipeline = new InterceptorPipeline();
19
    }
20
21
    public function withInterceptors(InterceptorInterface ...$interceptors): static
22
    {
23
        $clone = clone $this;
24
        $clone->pipeline = $this->pipeline->withInterceptors(...$interceptors);
25
        return $clone;
26
    }
27
28
    public function build(HandlerInterface $last): HandlerInterface
29
    {
30
        return $this->pipeline->withHandler($last);
31
    }
32
}
33