Completed
Pull Request — master (#3)
by Marcel
03:42
created

Request   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 57
ccs 15
cts 15
cp 1
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 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