Failed Conditions
Pull Request — release/3.0.0-dev (#32)
by Yo
01:46
created

OnExceptionEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setException() 0 5 1
A getFromJsonRpcRequest() 0 3 1
A getException() 0 3 1
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 a response has been successfully serialized by the endpoint and will be returned
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
    public function __construct(\Exception $exception, JsonRpcRequest $fromJsonRpcRequest = null)
26
    {
27
        $this->exception = $exception;
28
        $this->fromJsonRpcRequest = $fromJsonRpcRequest;
29
    }
30
31
    /**
32
     * @return \Exception
33
     */
34
    public function getException() : \Exception
35
    {
36
        return $this->exception;
37
    }
38
39
    /**
40
     * @return null|JsonRpcRequest
41
     */
42
    public function getFromJsonRpcRequest()
43
    {
44
        return $this->fromJsonRpcRequest;
45
    }
46
47
    /**
48
     * @param \Exception $exception
49
     *
50
     * @return OnExceptionEvent
51
     */
52
    public function setException(\Exception $exception) : OnExceptionEvent
53
    {
54
        $this->exception = $exception;
55
56
        return $this;
57
    }
58
}
59