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

OmsRequestErrorException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 36.36 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 16
loc 44
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A becauseOfError() 8 8 1
A becauseResponseIsIncorrect() 8 8 1
A getResponse() 0 4 1
A getResponseCode() 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
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