Passed
Pull Request — master (#1104)
by Aleksei
26:20
created

InterceptableCore::addInterceptor()   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 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Core;
6
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
use Spiral\Interceptors\Context\CallContext;
9
use Spiral\Interceptors\HandlerInterface;
10
use Spiral\Interceptors\InterceptorInterface;
11
12
/**
13
 * The domain core with a set of domain action interceptors (business logic middleware).
14
 *
15
 * @deprecated use {@see \Spiral\Interceptors\Handler\InterceptorPipeline} instead
16
 */
17
final class InterceptableCore implements CoreInterface, HandlerInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Spiral\Core\CoreInterface has been deprecated: Use {@see HandlerInterface} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

17
final class InterceptableCore implements /** @scrutinizer ignore-deprecated */ CoreInterface, HandlerInterface

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
18
{
19
    private InterceptorPipeline $pipeline;
20
21 3
    public function __construct(
22
        private readonly CoreInterface $core,
23
        ?EventDispatcherInterface $dispatcher = null
24
    ) {
25 3
        $this->pipeline = new InterceptorPipeline($dispatcher);
0 ignored issues
show
Deprecated Code introduced by
The class Spiral\Core\InterceptorPipeline has been deprecated: use {@see \Spiral\Interceptors\Handler\InterceptorPipeline} instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

25
        $this->pipeline = /** @scrutinizer ignore-deprecated */ new InterceptorPipeline($dispatcher);
Loading history...
26
    }
27
28 2
    public function addInterceptor(CoreInterceptorInterface|InterceptorInterface $interceptor): void
29
    {
30 2
        $this->pipeline->addInterceptor($interceptor);
31
    }
32
33 3
    public function callAction(string $controller, string $action, array $parameters = []): mixed
34
    {
35 3
        return $this->pipeline->withCore($this->core)->callAction($controller, $action, $parameters);
36
    }
37
38
    public function handle(CallContext $context): mixed
39
    {
40
        return $this->pipeline->withCore($this->core)->handle($context);
41
    }
42
}
43