RequestObject   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 17
c 0
b 0
f 0
dl 0
loc 46
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getProtocol() 0 3 1
A jsonSerialize() 0 7 1
A getMethod() 0 3 1
A getParams() 0 3 1
A __construct() 0 5 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