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

ValidateParamsEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 67
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getViolationList() 0 3 1
A __construct() 0 4 1
A addViolation() 0 5 1
A getParamList() 0 3 1
A setViolationList() 0 5 1
A getMethod() 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\JsonRpcMethodInterface;
6
7
/**
8
 * Class ValidateParamsEvent
9
 *
10
 * Dispatched before JSON-RPC will be called, in order to validate params
11
 */
12
class ValidateParamsEvent implements JsonRpcServerEvent
13
{
14
    const EVENT_NAME = 'json_rpc_server_skd.validate_params';
15
16
    /** @var JsonRpcMethodInterface */
17
    private $method;
18
    /** @var array */
19
    private $paramList = [];
20
    /** @var mixed[] */
21
    private $violationList = [];
22
23
    /**
24
     * @param JsonRpcMethodInterface $method
25
     * @param array                  $paramList
26
     */
27
    public function __construct(JsonRpcMethodInterface $method, array $paramList)
28
    {
29
        $this->method = $method;
30
        $this->paramList = $paramList;
31
    }
32
33
    /**
34
     * @return JsonRpcMethodInterface
35
     */
36
    public function getMethod() : JsonRpcMethodInterface
37
    {
38
        return $this->method;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getParamList() : array
45
    {
46
        return $this->paramList;
47
    }
48
49
    /**
50
     * @param array $violationList
51
     *
52
     * @return ValidateParamsEvent
53
     */
54
    public function setViolationList(array $violationList) : ValidateParamsEvent
55
    {
56
        $this->violationList = $violationList;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @param mixed $violation
63
     *
64
     * @return ValidateParamsEvent
65
     */
66
    public function addViolation($violation) : ValidateParamsEvent
67
    {
68
        $this->violationList[] = $violation;
69
70
        return $this;
71
    }
72
73
    /**
74
     * @return array
75
     */
76
    public function getViolationList() : array
77
    {
78
        return $this->violationList;
79
    }
80
}
81