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

OnMethodFailureEvent::getException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Yoanm\JsonRpcServer\Domain\Event\Action;
3
4
use Yoanm\JsonRpcServer\Domain\JsonRpcMethodInterface;
5
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcRequest;
6
7
/**
8
 * Class OnMethodFailureEvent
9
 *
10
 * Dispatched only in case JSON-RPC method thrown an exception.
11
 */
12
class OnMethodFailureEvent extends AbstractOnMethodEvent
13
{
14
    const EVENT_NAME = 'json_rpc_server_skd.on_method_failure';
15
16
    /** @var \Exception */
17
    private $exception;
18
19
    /**
20
     * @param \Exception             $exception
21
     * @param JsonRpcMethodInterface $method
22
     * @param JsonRpcRequest         $jsonRpcRequest
23
     */
24
    public function __construct(
25
        \Exception $exception,
26
        JsonRpcMethodInterface $method,
27
        JsonRpcRequest $jsonRpcRequest
28
    ) {
29
        $this->exception = $exception;
30
31
        parent::__construct($method, $jsonRpcRequest);
32
    }
33
34
    /**
35
     * @return \Exception
36
     */
37
    public function getException() : \Exception
38
    {
39
        return $this->exception;
40
    }
41
42
    /**
43
     * @param \Exception $exception
44
     *
45
     * @return OnMethodFailureEvent
46
     */
47
    public function setException(\Exception $exception) : OnMethodFailureEvent
48
    {
49
        $this->exception = $exception;
50
51
        return $this;
52
    }
53
}
54