Passed
Push — master ( 08894b...cd03f9 )
by Joachim
06:58
created

RequestException::getRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\DAO\Exception;
6
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use RuntimeException;
10
use Safe\Exceptions\StringsException;
11
use function Safe\sprintf;
12
13
abstract class RequestException extends RuntimeException
14
{
15
    /**
16
     * @var RequestInterface
17
     */
18
    private $request;
19
20
    /**
21
     * @var ResponseInterface
22
     */
23
    private $response;
24
25
    /**
26
     * @var int
27
     */
28
    private $statusCode;
29
30
    /**
31
     * @throws StringsException
32
     */
33
    public function __construct(RequestInterface $request, ResponseInterface $response, int $statusCode)
34
    {
35
        $this->request = $request;
36
        $this->response = $response;
37
        $this->statusCode = $statusCode;
38
39
        parent::__construct(sprintf('Request failed with status code %d', $this->statusCode));
40
    }
41
42
    public function getRequest(): RequestInterface
43
    {
44
        return $this->request;
45
    }
46
47
    public function getResponse(): ResponseInterface
48
    {
49
        return $this->response;
50
    }
51
52
    public function getStatusCode(): int
53
    {
54
        return $this->statusCode;
55
    }
56
}
57