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

Core   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 21
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A callAction() 0 5 1
A handle() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Events\Interceptor;
6
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
use Spiral\Core\CoreInterface;
9
use Spiral\Interceptors\Context\CallContext;
10
use Spiral\Interceptors\HandlerInterface;
11
12
/**
13
 * @psalm-type TParameters = array{event: object}
14
 */
15
final class Core 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

15
final class Core 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...
16
{
17 7
    public function __construct(
18
        private readonly EventDispatcherInterface $dispatcher
19
    ) {
20 7
    }
21
22
    /**
23
     * @param string $controller event name
24
     * @param-assert TParameters $parameters
25
     */
26 1
    public function callAction(string $controller, string $action, array $parameters = []): object
27
    {
28 1
        \assert(\is_object($parameters['event']));
29
30 1
        return $this->dispatcher->dispatch($parameters['event']);
31
    }
32
33
    public function handle(CallContext $context): mixed
34
    {
35
        return $this->dispatcher->dispatch($context->getArguments()['event']);
36
    }
37
}
38