Completed
Push — master ( 5c78d7...6647db )
by thomas
8s
created

ApiError::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BitWasp\Stratum\Exceptions;
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' => parent::getMessage()
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getMessage() instead of write()). Are you sure this is correct? If so, you might want to change this to $this->getMessage().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
38 1
        ]) . "\n";
39
    }
40
}
41