Passed
Push — master ( f0ad5e...b22a88 )
by Marcel
04:24
created

Request   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 57
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A method() 0 3 1
A params() 0 3 1
A id() 0 3 1
A jsonSerialize() 0 3 1
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
    public function __construct(Input $input)
33
    {
34
        \assert($input->isRpcRequest());
35
36
        $this->raw = $input->data();
37
38
        $this->id = $this->raw->id ?? null;
39
        $this->method = $this->raw->method;
40
        $this->params = $this->raw->params ?? null;
41
    }
42
43
    /**
44
     * @return int|string|null
45
     */
46
    public function id()
47
    {
48
        return $this->id;
49
    }
50
51
    public function method(): string
52
    {
53
        return $this->method;
54
    }
55
56
    /**
57
     * @return stdClass|array|null
58
     */
59
    public function params()
60
    {
61
        return $this->params;
62
    }
63
64
    public function jsonSerialize()
65
    {
66
        return $this->raw;
67
    }
68
}
69