Passed
Push — master ( a4e211...c5e421 )
by Nate
04:14
created

ResponseHandlingFailedException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 48
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getRequest() 0 4 1
A getResponse() 0 4 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Exception;
10
11
use Psr\Http\Message\RequestInterface;
12
use Psr\Http\Message\ResponseInterface;
13
use RuntimeException;
14
use Throwable;
15
16
/**
17
 * Class ResponseConversionFailedException
18
 *
19
 * This exception is thrown if there's an issue handling the response. It exists
20
 * in order to provide more information about the request/response to the consumer in
21
 * the event of a failure. It signifies that an HTTP request was successful, but could
22
 * not be properly handled.
23
 *
24
 * @author Nate Brunette <[email protected]>
25
 */
26
class ResponseHandlingFailedException extends RuntimeException
27
{
28
    /**
29
     * @var RequestInterface
30
     */
31
    private $request;
32
33
    /**
34
     * @var ResponseInterface
35
     */
36
    private $response;
37
38
    /**
39
     * Constructor
40
     *
41
     * @param RequestInterface $request
42
     * @param ResponseInterface $response
43
     * @param string $message
44
     * @param Throwable|null $previous
45
     */
46 4
    public function __construct(
47
        RequestInterface $request,
48
        ResponseInterface $response,
49
        string $message = '',
50
        Throwable $previous = null
51
    ) {
52 4
        parent::__construct($message, 0, $previous);
53
54 4
        $this->request = $request;
55 4
        $this->response = $response;
56 4
    }
57
58
    /**
59
     * @return RequestInterface
60
     */
61 4
    public function getRequest(): RequestInterface
62
    {
63 4
        return $this->request;
64
    }
65
66
    /**
67
     * @return ResponseInterface
68
     */
69 4
    public function getResponse(): ResponseInterface
70
    {
71 4
        return $this->response;
72
    }
73
}
74