ApiError::__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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace BitWasp\Stratum\Exception;
4
5
class ApiError extends \Exception
6
{
7
    /**
8
     * @var string
9
     */
10
    private $id;
11
12
    /**
13
     * @param string $id
14
     * @param int $error
15
     */
16 1
    public function __construct($id, $error)
17
    {
18 1
        $this->id = $id;
19 1
        parent::__construct($error);
20 1
    }
21
22
    /**
23
     * @return string
24
     */
25 1
    public function getId()
26
    {
27 1
        return $this->id;
28
    }
29
30
    /**
31
     * @return string
32
     */
33 1
    public function write()
34
    {
35 1
        return json_encode([
36 1
            'id' => $this->id,
37 1
            'error' => $this->getMessage()
38 1
        ]) . "\n";
39
    }
40
}
41