UnknownErrorResponseException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 17.07 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 7
loc 41
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __toString() 7 7 1
A getResponse() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php declare(strict_types=1);
2
3
namespace Fazland\SkebbyRestClient\Exception;
4
5
/**
6
 * Represents an unknown error response exception.
7
 *
8
 * @author Massimiliano Braglia <[email protected]>
9
 */
10
class UnknownErrorResponseException extends Exception
11
{
12
    /**
13
     * @var string|null
14
     */
15
    private $response;
16
17
    /**
18
     * UnknownErrorResponseException constructor.
19
     *
20
     * @param string      $message
21
     * @param string|null $response
22
     */
23 1
    public function __construct(string $message = '', string $response = null)
24
    {
25 1
        $this->response = $response;
26
27 1
        parent::__construct($message);
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 View Code Duplication
    public function __toString(): string
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        return '['.get_class($this).'] '.$this->message."\n".
36
            'Response: '."\n".
37
            $this->response
38
        ;
39
    }
40
41
    /**
42
     * Gets the Unknown error response.
43
     *
44
     * @return string|null
45
     */
46
    public function getResponse()
47
    {
48
        return $this->response;
49
    }
50
}
51