AbstractRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 62
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
isNotification() 0 1 ?
A jsonrpc() 0 4 1
A method() 0 4 1
A params() 0 4 1
1
<?php
2
3
namespace PhpJsonRpc\Server\Request;
4
5
use PhpJsonRpc\Server\Error\ParseError;
6
use PhpJsonRpc\Server\Error\InvalidRequest;
7
8
abstract class AbstractRequest
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $jsonrpc;
14
15
    /**
16
     * @var string
17
     */
18
    protected $method;
19
20
    /**
21
     * @var null|Params
22
     */
23
    protected $params;
24
25
    /**
26
     * @param \stdClass $jsonRpcMessage
27
     *
28
     * @throws InvalidRequest
29
     * @throws ParseError
30
     */
31 21
    public function __construct(\stdClass $jsonRpcMessage)
32
    {
33 21
        $this->jsonrpc  = $jsonRpcMessage->jsonrpc;
34 21
        $this->method   = $jsonRpcMessage->method;
35
36 21
        if (property_exists($jsonRpcMessage, 'params')) {
37 6
            $this->params = new Params($jsonRpcMessage->params);
38 6
        }
39 21
    }
40
41
    /**
42
     * @return bool
43
     */
44
    abstract public function isNotification();
45
46
    /**
47
     * @return string
48
     */
49
    public function jsonrpc()
50
    {
51
        return $this->jsonrpc;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 15
    public function method()
58
    {
59 15
        return $this->method;
60
    }
61
62
    /**
63
     * @return null|Params
64
     */
65 12
    public function params()
66
    {
67 12
        return $this->params;
68
    }
69
}
70