dispatchJsonRpcEvent()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
namespace Yoanm\JsonRpcServer\App\Dispatcher;
3
4
use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent;
5
use Yoanm\JsonRpcServer\Domain\JsonRpcServerDispatcherInterface;
6
7
/**
8
 * Class JsonRpcServerDispatcherAwareTrait
9
 */
10
trait JsonRpcServerDispatcherAwareTrait
11
{
12
    /** @var JsonRpcServerDispatcherInterface */
13
    private $jsonRpcServerDispatcher = null;
14
15
    /**
16
     * @param JsonRpcServerDispatcherInterface $jsonRpcServerDispatcher
17
     */
18 22
    public function setJsonRpcServerDispatcher(JsonRpcServerDispatcherInterface $jsonRpcServerDispatcher) : void
19
    {
20 22
        $this->jsonRpcServerDispatcher = $jsonRpcServerDispatcher;
21
    }
22
23
    /**
24
     * @param string                  $eventName
25
     * @param JsonRpcServerEvent|null $event
26
     *
27
     * @return void
28
     */
29 63
    protected function dispatchJsonRpcEvent(string $eventName, JsonRpcServerEvent $event = null) : void
30
    {
31
        // Do nothing if dispatcher is not there
32 63
        if ($this->jsonRpcServerDispatcher) {
33 21
            $this->jsonRpcServerDispatcher->dispatchJsonRpcEvent($eventName, $event);
34
        }
35
    }
36
}
37