1 | <?php |
||
7 | final class JsonRpcRequest implements JsonRpcRequestInterface |
||
8 | { |
||
9 | /** @var string */ |
||
10 | private $id; |
||
11 | /** @var string */ |
||
12 | private $method; |
||
13 | /** @var \stdClass|array|null */ |
||
14 | private $parameters; |
||
15 | |||
16 | /** |
||
17 | * JsonRpcRequest constructor. |
||
18 | * @param string $method |
||
19 | * @param \stdClass|array|null $parameters |
||
20 | * @param string $id |
||
21 | */ |
||
22 | 16 | public function __construct($method, $parameters = null, $id = null) |
|
28 | |||
29 | /** |
||
30 | * @param RpcRequestInterface $request |
||
31 | * @param string $id |
||
32 | * @return static |
||
33 | */ |
||
34 | 1 | public static function fromRpcRequest(RpcRequestInterface $request, $id) |
|
35 | { |
||
36 | 1 | return new static($request->getMethod(), $request->getParameters(), $id); |
|
37 | } |
||
38 | |||
39 | /** {@inheritdoc} */ |
||
40 | 16 | public function isNotification() |
|
44 | |||
45 | /** {@inheritdoc} */ |
||
46 | 16 | public function getId() |
|
50 | |||
51 | /** {@inheritdoc} */ |
||
52 | 16 | public function getMethod() |
|
56 | |||
57 | /** {@inheritdoc} */ |
||
58 | 16 | public function getParameters() |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 16 | public function jsonSerialize() |
|
80 | |||
81 | /** |
||
82 | * Returns version of the JSON-RPC request |
||
83 | * |
||
84 | * A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0". |
||
85 | * |
||
86 | * @return string JSON-RPC version |
||
87 | */ |
||
88 | public function getVersion() |
||
92 | } |
||
93 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.