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 | * __construct |
||
39 | * |
||
40 | * Instantiates a new response object |
||
41 | * |
||
42 | * @param int $status_code the HTTP status code |
||
43 | * @param string $sent_headers the headers sent |
||
44 | * @param string $received_headers the headers received |
||
45 | * @param string $response_data the http response body |
||
46 | */ |
||
47 | 4 | public function __construct($status_code, $sent_headers, $received_headers, $response_data) |
|
54 | |||
55 | /** |
||
56 | * asRaw |
||
57 | * |
||
58 | * Returns the HTTP status code, headers and response body. |
||
59 | * Usage: list($status_code, $headers, $response_body) = $response->as_raw(). |
||
60 | * |
||
61 | * @param boolan $keep_authorization_value Normally the value of the |
||
62 | * Authorization: header is masked. True keeps the sent value. |
||
63 | * @return array [integer, string[], string] |
||
64 | */ |
||
65 | public function asRaw($keep_authorization_value = false) |
||
90 | |||
91 | /** |
||
92 | * asArray |
||
93 | * |
||
94 | * Returns the response body as an array |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public function asArray() |
||
106 | |||
107 | /** |
||
108 | * asObject |
||
109 | * |
||
110 | * Returns the response body as an array |
||
111 | * |
||
112 | * @return \stdClass |
||
113 | */ |
||
114 | public function asObject() |
||
122 | |||
123 | /** |
||
124 | * httpStatus |
||
125 | * |
||
126 | * Returns the http_status code |
||
127 | * |
||
128 | * @return int |
||
129 | */ |
||
130 | 1 | public function httpStatus() |
|
134 | |||
135 | /** |
||
136 | * isSuccess |
||
137 | * |
||
138 | * Checks if the http status code indicates a succesful or an error response. |
||
139 | * |
||
140 | * @return boolean |
||
141 | */ |
||
142 | 2 | public function isSuccess() |
|
150 | } |
||
151 |