Completed
Push — master ( 6647db...0cc2fc )
by thomas
7s
created

ApiError   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A write() 0 7 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