OnExceptionEvent::setException()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
namespace Yoanm\JsonRpcServer\Domain\Event\Action;
3
4
use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent;
5
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcRequest;
6
7
/**
8
 * Class OnExceptionEvent
9
 *
10
 * Dispatched when an exception occurred during sdk execution (For method execution exception see OnMethodFailureEvent)
11
 */
12
class OnExceptionEvent implements JsonRpcServerEvent
13
{
14
    const EVENT_NAME = 'json_rpc_server_skd.on_exception';
15
16
    /** @var \Exception */
17
    private $exception;
18
    /** @var null|JsonRpcRequest */
19
    private $fromJsonRpcRequest;
20
21
    /**
22
     * @param \Exception          $exception
23
     * @param JsonRpcRequest|null $fromJsonRpcRequest
24
     */
25 32
    public function __construct(\Exception $exception, JsonRpcRequest $fromJsonRpcRequest = null)
26
    {
27 32
        $this->exception = $exception;
28 32
        $this->fromJsonRpcRequest = $fromJsonRpcRequest;
29
    }
30
31
    /**
32
     * @return \Exception
33
     */
34 31
    public function getException() : \Exception
35
    {
36 31
        return $this->exception;
37
    }
38
39
    /**
40
     * @return null|JsonRpcRequest
41
     */
42 1
    public function getFromJsonRpcRequest() : ?JsonRpcRequest
43
    {
44 1
        return $this->fromJsonRpcRequest;
45
    }
46
47
    /**
48
     * @param \Exception $exception
49
     *
50
     * @return self
51
     */
52 3
    public function setException(\Exception $exception) : self
53
    {
54 3
        $this->exception = $exception;
55
56 3
        return $this;
57
    }
58
}
59