Total Complexity | 10 |
Total Lines | 107 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
9 | class JsonRpcResponse |
||
10 | { |
||
11 | const DEFAULT_VERSION = '2.0'; |
||
12 | |||
13 | /** @var string */ |
||
14 | private $jsonRpc; |
||
15 | /** @var mixed */ |
||
16 | private $result = null; |
||
17 | /** @var null|JsonRpcExceptionInterface */ |
||
18 | private $error = null; |
||
19 | /** @var mixed */ |
||
20 | private $id = null; |
||
21 | /** @var bool */ |
||
22 | private $isNotification = false; |
||
23 | |||
24 | /** |
||
25 | * @param string $jsonRpc |
||
26 | */ |
||
27 | public function __construct(string $jsonRpc = self::DEFAULT_VERSION) |
||
28 | { |
||
29 | $this->jsonRpc = $jsonRpc; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param mixed $result |
||
34 | * |
||
35 | * @return JsonRpcResponse |
||
36 | */ |
||
37 | public function setResult($result) : JsonRpcResponse |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param JsonRpcExceptionInterface $error |
||
46 | * |
||
47 | * @return JsonRpcResponse |
||
48 | */ |
||
49 | public function setError(JsonRpcExceptionInterface $error) : JsonRpcResponse |
||
50 | { |
||
51 | $this->error = $error; |
||
52 | |||
53 | return $this; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param mixed $id |
||
58 | * |
||
59 | * @return JsonRpcResponse |
||
60 | */ |
||
61 | public function setId($id) : JsonRpcResponse |
||
62 | { |
||
63 | $this->id = $id; |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param bool $isNotification |
||
70 | */ |
||
71 | public function setIsNotification(bool $isNotification) : JsonRpcResponse |
||
72 | { |
||
73 | $this->isNotification = $isNotification; |
||
74 | |||
75 | return $this; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getJsonRpc() : string |
||
82 | { |
||
83 | return $this->jsonRpc; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @return mixed |
||
88 | */ |
||
89 | public function getResult() |
||
90 | { |
||
91 | return $this->result; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return JsonRpcExceptionInterface|null |
||
96 | */ |
||
97 | public function getError() |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @return string|int|null |
||
104 | */ |
||
105 | public function getId() |
||
106 | { |
||
107 | return $this->id; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function isNotification() : bool |
||
116 | } |
||
117 | } |
||
118 |