Total Complexity | 10 |
Total Lines | 88 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class JsonRpcRequest |
||
10 | { |
||
11 | /** @var string */ |
||
12 | private $jsonRpc; |
||
13 | /** @var string */ |
||
14 | private $method; |
||
15 | /** @var array */ |
||
16 | private $paramList = []; |
||
17 | /** @var int|string|null */ |
||
18 | private $id = null; |
||
19 | |||
20 | /** |
||
21 | * @param string $jsonRpc |
||
22 | * @param string $method |
||
23 | */ |
||
24 | 34 | public function __construct(string $jsonRpc, string $method) |
|
25 | { |
||
26 | 34 | $this->jsonRpc = $jsonRpc; |
|
27 | 34 | $this->method = $method; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param array $paramList |
||
32 | * |
||
33 | * @return self |
||
34 | */ |
||
35 | 9 | public function setParamList(array $paramList) : self |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param mixed $id |
||
44 | * |
||
45 | * @throws InvalidArgumentException |
||
46 | * @return self |
||
47 | */ |
||
48 | 23 | public function setId($id) : self |
|
49 | { |
||
50 | 23 | if (!is_string($id) && !is_int($id)) { |
|
51 | 5 | throw new InvalidArgumentException('Id must be either an int or a string'); |
|
52 | } |
||
53 | |||
54 | 18 | $this->id = $id; |
|
55 | |||
56 | 18 | return $this; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | 22 | public function getJsonRpc() : string |
|
63 | { |
||
64 | 22 | return $this->jsonRpc; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | 22 | public function getMethod() : string |
|
71 | { |
||
72 | 22 | return $this->method; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | 19 | public function getParamList() : array |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return string|int|null |
||
85 | */ |
||
86 | 18 | public function getId() |
|
87 | { |
||
88 | 18 | return $this->id; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | 22 | public function isNotification() : bool |
|
97 | } |
||
98 | } |
||
99 |