Passed
Push — master ( b22a88...886da7 )
by Marcel
02:28
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 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