Completed
Push — master ( f3d222...548fd9 )
by Agaletskiy
01:48
created

becauseResponseIsIncorrect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\OmsClient\Exception;
6
7
final class OmsRequestErrorException extends \RuntimeException implements OmsClientExceptionInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $response;
13
    /**
14
     * @var int
15
     */
16
    private $responseCode;
17
18
    private function __construct($message = '', $code = 0, \Throwable $previous = null)
19
    {
20
        parent::__construct($message, $code, $previous);
21
    }
22
23 View Code Duplication
    public static function becauseOfError(int $responseCode, string $response, \Throwable $exception): self
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...
24
    {
25
        $self = new static('Request to OMS finished with error', 0, $exception);
26
        $self->response = $response;
27
        $self->responseCode = $responseCode;
28
29
        return $self;
30
    }
31
32 View Code Duplication
    public static function becauseResponseIsIncorrect(int $responseCode, string $response): self
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...
33
    {
34
        $self = new static('Request to OMS is incorrect');
35
        $self->response = $response;
36
        $self->responseCode = $responseCode;
37
38
        return $self;
39
    }
40
41
    public function getResponse(): string
42
    {
43
        return $this->response;
44
    }
45
46
    public function getResponseCode(): int
47
    {
48
        return $this->responseCode;
49
    }
50
}
51