IsmpRequestErrorException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A becauseOfErrorResponse() 0 12 1
A getResponse() 0 4 1
A getResponseCode() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\IsmpClient\Exception;
6
7
final class IsmpRequestErrorException extends \RuntimeException implements IsmpClientExceptionInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $response;
13
    /**
14
     * @var int
15
     */
16
    private $responseCode;
17
18
    public static function becauseOfErrorResponse(int $responseCode, string $response, \Throwable $exception): self
19
    {
20
        $self = new static(sprintf(
21
            'Request to ISMP finished with error response and message "%s"',
22
            $exception->getMessage()
23
        ), 0, $exception);
24
25
        $self->responseCode = $responseCode;
26
        $self->response = $response;
27
28
        return $self;
29
    }
30
31
    public function getResponse(): string
32
    {
33
        return $this->response;
34
    }
35
36
    public function getResponseCode(): int
37
    {
38
        return $this->responseCode;
39
    }
40
}
41