1 | <?php |
||
10 | final class Response |
||
11 | { |
||
12 | /** |
||
13 | * The http status of the response. |
||
14 | * |
||
15 | * @var int |
||
16 | */ |
||
17 | private $httpCode; |
||
18 | |||
19 | /** |
||
20 | * The response from the API |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | private $body; |
||
25 | |||
26 | /** |
||
27 | * A array of headers received with the response. |
||
28 | * |
||
29 | * @var array array where each header key has an array of values |
||
30 | */ |
||
31 | private $headers; |
||
32 | |||
33 | /** |
||
34 | * Create a new instance of Response |
||
35 | * |
||
36 | * @param int $httpCode |
||
37 | * @param array $headers |
||
38 | * @param array $body |
||
39 | * |
||
40 | * @throws \InvalidArgumentException Throw if $httpCode is not an integer between 100 and 600 |
||
41 | */ |
||
42 | public function __construct($httpCode, array $headers, array $body = []) |
||
54 | |||
55 | /** |
||
56 | * Returns the HTTP status code of the response |
||
57 | * |
||
58 | * @return int |
||
59 | */ |
||
60 | public function getHttpCode() |
||
64 | |||
65 | /** |
||
66 | * Returns an array representing the response from the API |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | public function getResponse() |
||
74 | |||
75 | /** |
||
76 | * Returns the parsed response headers from the API |
||
77 | * |
||
78 | * @return array array where each header key has an array of values |
||
79 | */ |
||
80 | public function getResponseHeaders() |
||
84 | } |
||
85 |