1 | <?php |
||||||
2 | |||||||
3 | namespace Multicoin\Api\Exceptions; |
||||||
4 | |||||||
5 | use Http\Client\Common\Exception\ClientErrorException; |
||||||
6 | use Psr\Http\Message\RequestInterface; |
||||||
7 | use Psr\Http\Message\ResponseInterface; |
||||||
8 | use Throwable; |
||||||
9 | |||||||
10 | class RequestFailedException extends ClientErrorException |
||||||
11 | { |
||||||
12 | /** |
||||||
13 | * @var RequestInterface |
||||||
14 | */ |
||||||
15 | protected $httpRequest; |
||||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||||
16 | /** |
||||||
17 | * @var ResponseInterface |
||||||
18 | */ |
||||||
19 | protected $httpResponse; |
||||||
0 ignored issues
–
show
|
|||||||
20 | |||||||
21 | /** |
||||||
22 | * HttpRequestFailedException constructor. |
||||||
23 | * |
||||||
24 | * @param RequestInterface|ResponseInterface $requestOrResponse |
||||||
25 | * @param int $code |
||||||
26 | * @param null|Throwable $previous |
||||||
27 | */ |
||||||
28 | public function __construct($requestOrResponse, int $code = 0, Throwable $previous = null) |
||||||
29 | { |
||||||
30 | if ($requestOrResponse instanceof ResponseInterface) { |
||||||
31 | parent::__construct( |
||||||
32 | 'The HTTP request Response failed with the status code '.$requestOrResponse->getStatusCode(), |
||||||
33 | $requestOrResponse->getRequest(), |
||||||
0 ignored issues
–
show
The method
getRequest() does not exist on Psr\Http\Message\ResponseInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
34 | $requestOrResponse->getReasponse(), |
||||||
0 ignored issues
–
show
The method
getReasponse() does not exist on Psr\Http\Message\ResponseInterface . Did you maybe mean getReasonPhrase() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
35 | $previous |
||||||
36 | ); |
||||||
37 | $this->httpResponse = $requestOrResponse; |
||||||
38 | } |
||||||
39 | |||||||
40 | if ($requestOrResponse instanceof RequestInterface) { |
||||||
41 | $this->httpRequest = $requestOrResponse; |
||||||
42 | } |
||||||
43 | } |
||||||
44 | |||||||
45 | /** |
||||||
46 | * @return RequestInterface |
||||||
47 | */ |
||||||
48 | public function getHttpRequest() |
||||||
49 | { |
||||||
50 | return $this->httpRequest; |
||||||
51 | } |
||||||
52 | |||||||
53 | /** |
||||||
54 | * @return ResponseInterface |
||||||
55 | */ |
||||||
56 | public function getHttpResponse() |
||||||
57 | { |
||||||
58 | return $this->httpResponse; |
||||||
59 | } |
||||||
60 | } |
||||||
61 |