OnMethodFailureEvent::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\JsonRpcMethodInterface;
5
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcRequest;
6
7
/**
8
 * Class OnMethodFailureEvent
9
 *
10
 * Dispatched only in case JSON-RPC method throw an exception during execution
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 9
    public function __construct(
25
        \Exception $exception,
26
        JsonRpcMethodInterface $method,
27
        JsonRpcRequest $jsonRpcRequest
28
    ) {
29 9
        $this->exception = $exception;
30
31 9
        parent::__construct($method, $jsonRpcRequest);
32
    }
33
34
    /**
35
     * @return \Exception
36
     */
37 9
    public function getException() : \Exception
38
    {
39 9
        return $this->exception;
40
    }
41
42
    /**
43
     * @param \Exception $exception
44
     *
45
     * @return self
46
     */
47 3
    public function setException(\Exception $exception) : self
48
    {
49 3
        $this->exception = $exception;
50
51 3
        return $this;
52
    }
53
}
54