RequestObject::getParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * This file is part of JSON RPC Client.
4
 *
5
 * (c) Igor Lazarev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Strider2038\JsonRpcClient\Request;
12
13
/**
14
 * @author Igor Lazarev <[email protected]>
15
 */
16
class RequestObject implements RequestObjectInterface, \JsonSerializable
17
{
18
    private string $jsonrpc = '2.0';
19
20
    private string $method;
21
22
    /** @var mixed */
23
    private $params;
24
25
    /** @var string|int */
26
    private $id;
27
28
    public function __construct($id, string $method, $params)
29
    {
30 51
        $this->id = $id;
31
        $this->method = $method;
32 51
        $this->params = $params;
33 51
    }
34 51
35 51
    public function getId()
36
    {
37 13
        return $this->id;
38
    }
39 13
40
    public function getProtocol(): string
41
    {
42 2
        return $this->jsonrpc;
43
    }
44 2
45
    public function getMethod(): string
46
    {
47 8
        return $this->method;
48
    }
49 8
50
    public function getParams()
51
    {
52 2
        return $this->params;
53
    }
54 2
55
    public function jsonSerialize(): array
56
    {
57 42
        return [
58
            'jsonrpc' => $this->jsonrpc,
59
            'method'  => $this->method,
60 42
            'params'  => $this->params,
61 42
            'id'      => $this->id,
62 42
        ];
63 42
    }
64
}
65