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

OnMethodFailureEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A setException() 0 5 1
A getException() 0 3 1
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