becauseOfErrorResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.8666
cc 1
nc 1
nop 3
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