1 | <?php |
||
7 | class Response |
||
8 | { |
||
9 | /** |
||
10 | * HTTP status code of request. |
||
11 | * |
||
12 | * @var integer |
||
13 | */ |
||
14 | protected $status_code; |
||
15 | |||
16 | /** |
||
17 | * The headers sent during the request. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $sent_headers; |
||
22 | |||
23 | /** |
||
24 | * The headers received during the request. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $received_headers; |
||
29 | |||
30 | /** |
||
31 | * Response body of last request. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $response_data; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Response constructor. |
||
40 | * @param $status_code |
||
41 | * @param $sent_headers |
||
42 | * @param $received_headers |
||
43 | * @param $response_data |
||
44 | */ |
||
45 | 4 | public function __construct($status_code, $sent_headers, $received_headers, $response_data) |
|
52 | |||
53 | |||
54 | /** |
||
55 | * @param bool $keep_authorization_value |
||
56 | * @return array |
||
57 | */ |
||
58 | public function asRaw($keep_authorization_value = false) |
||
83 | |||
84 | /** |
||
85 | * asArray |
||
86 | * |
||
87 | * Returns the response body as an array |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function asArray() |
||
99 | |||
100 | /** |
||
101 | * asObject |
||
102 | * |
||
103 | * Returns the response body as an array |
||
104 | * |
||
105 | * @return \stdClass |
||
106 | */ |
||
107 | public function asObject() |
||
115 | |||
116 | /** |
||
117 | * httpStatus |
||
118 | * |
||
119 | * Returns the http_status code |
||
120 | * |
||
121 | * @return int |
||
122 | */ |
||
123 | 1 | public function httpStatus() |
|
127 | |||
128 | /** |
||
129 | * isSuccess |
||
130 | * |
||
131 | * Checks if the http status code indicates a succesful or an error response. |
||
132 | * |
||
133 | * @return boolean |
||
134 | */ |
||
135 | 2 | public function isSuccess() |
|
143 | } |
||
144 |