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