UnsuccessfulResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 52
ccs 8
cts 14
cp 0.5714
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A id() 0 4 1
A error() 0 4 1
A jsonSerialize() 0 10 1
1
<?php
2
3
namespace PhpJsonRpc\Server\Response;
4
5
class UnsuccessfulResponse extends AbstractResponse
6
{
7
    /**
8
     * @var int|null
9
     */
10
    protected $id;
11
12
    /**
13
     * @var Error
14
     */
15
    protected $error;
16
17
    /**
18
     * @param int|null $id
19
     * @param Error $error
20
     */
21 18
    public function __construct($id, Error $error)
22
    {
23 18
        $this->id       = $id;
24 18
        $this->error    = $error;
25 18
    }
26
27
    /**
28
     * @return int|null
29
     */
30 3
    public function id()
31
    {
32 3
        return $this->id;
33
    }
34
35
    /**
36
     * @return Error
37
     */
38 18
    public function error()
39
    {
40 18
        return $this->error;
41
    }
42
43
    /**
44
     * @return \stdClass
45
     */
46
    public function jsonSerialize()
47
    {
48
        $jsonSerializable = new \stdClass();
49
50
        $jsonSerializable->jsonrpc  = $this->jsonrpc();
51
        $jsonSerializable->id       = $this->id();
52
        $jsonSerializable->error    = $this->error();
53
54
        return $jsonSerializable;
55
    }
56
}
57