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

Core::callAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 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