Error   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 0
dl 0
loc 51
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMessage() 0 4 1
A getCode() 0 4 1
A toArray() 0 7 1
1
<?php
2
3
namespace Tonic\Component\ApiLayer\JsonRpc\Response;
4
5
/**
6
 * Represents JSON-RPC error in response.
7
 */
8
class Error
9
{
10
    /**
11
     * @var string
12
     */
13
    private $message;
14
15
    /**
16
     * @var int
17
     */
18
    private $code;
19
20
    /**
21
     * Constructor.
22
     *
23
     * @param string $message
24
     * @param int    $code
25
     */
26
    public function __construct($message, $code)
27
    {
28
        $this->message = $message;
29
        $this->code = $code;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getMessage()
36
    {
37
        return $this->message;
38
    }
39
40
    /**
41
     * @return int
42
     */
43
    public function getCode()
44
    {
45
        return $this->code;
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public function toArray()
52
    {
53
        return [
54
            'code' => $this->getCode(),
55
            'message' => $this->getMessage(),
56
        ];
57
    }
58
}
59