1 | <?php |
||
12 | class Response |
||
13 | { |
||
14 | /** |
||
15 | * HTTP status code of request. |
||
16 | * |
||
17 | * @var integer |
||
18 | */ |
||
19 | protected $status_code; |
||
20 | |||
21 | /** |
||
22 | * The headers sent during the request. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $sent_headers; |
||
27 | |||
28 | /** |
||
29 | * The headers received during the request. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $received_headers; |
||
34 | |||
35 | /** |
||
36 | * Response body of last request. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $response_data; |
||
41 | |||
42 | /** |
||
43 | * __construct |
||
44 | * |
||
45 | * Instantiates a new response object |
||
46 | * |
||
47 | * @param int $status_code the HTTP status code |
||
48 | * @param string $sent_headers the headers sent |
||
49 | * @param string $received_headers the headers received |
||
50 | * @param string $response_data the http response body |
||
51 | */ |
||
52 | 19 | public function __construct($status_code, $sent_headers, $received_headers, $response_data) |
|
59 | |||
60 | /** |
||
61 | * asRaw |
||
62 | * |
||
63 | * Returns the HTTP status code, headers and response body. |
||
64 | * Usage: list($status_code, $headers, $response_body) = $response->as_raw(). |
||
65 | * |
||
66 | * @param boolan $keep_authorization_value Normally the value of the |
||
67 | * Authorization: header is masked. True keeps the sent value. |
||
68 | * @return array [integer, string[], string] |
||
69 | */ |
||
70 | 1 | public function asRaw($keep_authorization_value = false) |
|
95 | |||
96 | /** |
||
97 | * asArray |
||
98 | * |
||
99 | * Returns the response body as an array |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | 2 | public function asArray() |
|
111 | |||
112 | /** |
||
113 | * asObject |
||
114 | * |
||
115 | * Returns the response body as an array |
||
116 | * |
||
117 | * @return \stdClass |
||
118 | */ |
||
119 | 2 | public function asObject() |
|
127 | |||
128 | /** |
||
129 | * httpStatus |
||
130 | * |
||
131 | * Returns the http_status code |
||
132 | * |
||
133 | * @return int |
||
134 | */ |
||
135 | 4 | public function httpStatus() |
|
139 | |||
140 | /** |
||
141 | * isSuccess |
||
142 | * |
||
143 | * Checks if the http status code indicates a succesful or an error response. |
||
144 | * |
||
145 | * @return boolean |
||
146 | */ |
||
147 | 9 | public function isSuccess() |
|
155 | } |
||
156 |