Error::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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