JsonRpcNotification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ScayTrase\Api\JsonRpc;
4
5
final class JsonRpcNotification implements JsonRpcRequestInterface
6
{
7
    /** @var  string */
8
    private $method;
9
    /** @var  \stdClass|array|null */
10
    private $parameters;
11
12
    /**
13
     * JsonRpcNotificationRequest constructor.
14
     * @param string $method
15
     * @param \stdClass|array|null $parameters
16
     */
17 2
    public function __construct($method, $parameters)
18
    {
19 2
        $this->method = $method;
20 2
        $this->parameters = $parameters;
21 2
    }
22
23
    /** {@inheritdoc} */
24
    public function getId()
25
    {
26
        return null;
27
    }
28
29
    /** {@inheritdoc} */
30 2
    public function isNotification()
31
    {
32 2
        return true;
33
    }
34
35
    /** {@inheritdoc} */
36 2
    public function getMethod()
37
    {
38 2
        return $this->method;
39
    }
40
41
    /** {@inheritdoc} */
42 2
    public function getParameters()
43
    {
44 2
        return $this->parameters;
45
    }
46
47
    /** {@inheritdoc} */
48
    public function getVersion()
49
    {
50
        return JsonRpcClient::VERSION;
51
    }
52
53
    /** {@inheritdoc} */
54 2
    public function jsonSerialize()
55
    {
56
        return [
57 2
            self::VERSION_FIELD => JsonRpcClient::VERSION,
58 2
            self::METHOD_FIELD => $this->getMethod(),
59 2
            self::PARAMETERS_FIELD => $this->getParameters(),
60 2
        ];
61
    }
62
}
63