Total Complexity | 4 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 81.82% |
Changes | 0 |
1 | <?php |
||
9 | class WebserviceResponseException extends Exception |
||
10 | { |
||
11 | /** |
||
12 | * @var ResponseInterface |
||
13 | */ |
||
14 | private $reponse; |
||
15 | |||
16 | /** |
||
17 | * @var RequestInterface |
||
18 | */ |
||
19 | private $request; |
||
20 | |||
21 | private $body; |
||
22 | |||
23 | 7 | public function __construct(ResponseInterface $response, RequestInterface $request = null) |
|
24 | { |
||
25 | 7 | parent::__construct($response->getReasonPhrase(), $response->getStatusCode()); |
|
26 | |||
27 | 7 | $this->reponse = $response; |
|
28 | 7 | $this->request = $request; |
|
29 | 7 | } |
|
30 | |||
31 | 1 | public function getBody() |
|
32 | { |
||
33 | 1 | return $this->body ?? $this->body = json_decode($this->reponse->getBody()->getContents(), true); |
|
34 | } |
||
35 | |||
36 | public function getReponse(): ResponseInterface |
||
37 | { |
||
38 | return $this->reponse; |
||
39 | } |
||
40 | |||
41 | 1 | public function getRequest() |
|
44 | } |
||
45 | } |