Passed
Push — master ( 745402...3d5cea )
by Marcel
43s
created

Request::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UMA\JsonRpc;
6
7
use UMA\JsonRpc\Internal\Input;
8
9
class Request implements \JsonSerializable
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $raw;
15
16
    /**
17
     * @var int|string|null
18
     */
19
    private $id;
20
21
    /**
22
     * @var string
23
     */
24
    private $method;
25
26
    /**
27
     * @var \stdClass|array|null
28
     */
29
    private $params;
30
31 19
    public function __construct(Input $input)
32
    {
33 19
        \assert($input->isRpcRequest());
34
35 19
        $this->raw = $input->data();
36
37 19
        $this->id = $this->raw->id ?? null;
38 19
        $this->method = $this->raw->method;
39 19
        $this->params = $this->raw->params ?? null;
40 19
    }
41
42
    /**
43
     * @return int|string|null
44
     */
45 19
    public function id()
46
    {
47 19
        return $this->id;
48
    }
49
50 19
    public function method(): string
51
    {
52 19
        return $this->method;
53
    }
54
55
    /**
56
     * @return \stdClass|array|null
57
     */
58 12
    public function params()
59
    {
60 12
        return $this->params;
61
    }
62
63 1
    public function jsonSerialize()
64
    {
65 1
        return $this->raw;
66
    }
67
}
68