1 | <?php |
||
18 | final class HttpClientException extends \RuntimeException implements Exception |
||
19 | { |
||
20 | /** |
||
21 | * @var ResponseInterface|null |
||
22 | */ |
||
23 | private $response; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $responseBody; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | private $responseCode; |
||
34 | |||
35 | /** |
||
36 | * @param string $message |
||
37 | * @param int $code |
||
38 | * @param ResponseInterface|null $response |
||
39 | */ |
||
40 | 6 | public function __construct($message, $code, ResponseInterface $response = null) |
|
41 | { |
||
42 | 6 | parent::__construct($message, $code); |
|
43 | |||
44 | 6 | if ($response) { |
|
45 | 6 | $this->response = $response; |
|
46 | 6 | $this->responseCode = $response->getStatusCode(); |
|
47 | 6 | $body = $response->getBody()->__toString(); |
|
48 | 6 | if (0 !== strpos($response->getHeaderLine('Content-Type'), 'application/json')) { |
|
49 | $this->responseBody['message'] = $body; |
||
50 | } else { |
||
51 | 6 | $this->responseBody = json_decode($body, true); |
|
|
|||
52 | } |
||
53 | 6 | } |
|
54 | 6 | } |
|
55 | |||
56 | 2 | public static function badRequest(ResponseInterface $response = null) |
|
60 | |||
61 | public static function unauthorized(ResponseInterface $response = null) |
||
65 | |||
66 | public static function requestFailed(ResponseInterface $response = null) |
||
70 | |||
71 | 4 | public static function notFound(ResponseInterface $response = null) |
|
75 | |||
76 | public static function payloadTooLarge(ResponseInterface $response = null) |
||
80 | |||
81 | /** |
||
82 | * @return ResponseInterface |
||
83 | */ |
||
84 | public function getResponse() |
||
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | public function getResponseBody() |
||
96 | |||
97 | /** |
||
98 | * @return int |
||
99 | */ |
||
100 | public function getResponseCode() |
||
104 | } |
||
105 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..