Passed
Push — master ( b22a88...886da7 )
by Marcel
02:28
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 stdClass;
8
use UMA\JsonRpc\Internal\Input;
9
10
final class Request implements \JsonSerializable
11
{
12
    /**
13
     * @var mixed
14
     */
15
    private $raw;
16
17
    /**
18
     * @var int|string|null
19
     */
20
    private $id;
21
22
    /**
23
     * @var string
24
     */
25
    private $method;
26
27
    /**
28
     * @var stdClass|array|null
29
     */
30
    private $params;
31
32 20
    public function __construct(Input $input)
33
    {
34 20
        \assert($input->isRpcRequest());
35
36 20
        $this->raw = $input->data();
37
38 20
        $this->id = $this->raw->id ?? null;
39 20
        $this->method = $this->raw->method;
40 20
        $this->params = $this->raw->params ?? null;
41 20
    }
42
43
    /**
44
     * @return int|string|null
45
     */
46 18
    public function id()
47
    {
48 18
        return $this->id;
49
    }
50
51 19
    public function method(): string
52
    {
53 19
        return $this->method;
54
    }
55
56
    /**
57
     * @return stdClass|array|null
58
     */
59 13
    public function params()
60
    {
61 13
        return $this->params;
62
    }
63
64 2
    public function jsonSerialize()
65
    {
66 2
        return $this->raw;
67
    }
68
}
69