Completed
Pull Request — master (#16)
by Alessandro
06:12
created

UnknownErrorResponseException   A

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

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
2
3
declare(strict_types=1);
4
5
namespace Fazland\SkebbyRestClient\Exception;
6
7
use Throwable;
8
9
/**
10
 * Represents an unknown error response exception.
11
 */
12
class UnknownErrorResponseException extends Exception
13
{
14
    private ?string $response = null;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '?', expecting T_FUNCTION or T_CONST
Loading history...
15
16
    public function __construct(string $message = '', ?string $response = null, ?Throwable $previous = null)
17
    {
18
        $this->response = $response;
19
20
        parent::__construct($message, 0, $previous);
21
    }
22
23 1
    public function __toString(): string
24
    {
25 1
        return '[' . static::class . '] ' . $this->message . "\n" .
26
            'Response: ' . "\n" .
27 1
            $this->response;
28 1
    }
29
30
    /**
31
     * Gets the Unknown error response.
32
     */
33
    public function getResponse(): ?string
34
    {
35
        return $this->response;
36
    }
37
}
38