1 | <?php |
||
5 | class HttpRequest implements Request |
||
6 | { |
||
7 | protected $getParameters; |
||
8 | protected $postParameters; |
||
9 | protected $server; |
||
10 | protected $files; |
||
11 | protected $cookies; |
||
12 | |||
13 | public function __construct( |
||
26 | |||
27 | /** |
||
28 | * Returns a parameter value or a default value if none is set. |
||
29 | * |
||
30 | * @param string $key |
||
31 | * @param string $defaultValue (optional) |
||
32 | * @return string |
||
33 | */ |
||
34 | public function getParameter($key, $defaultValue = null) |
||
46 | |||
47 | /** |
||
48 | * Returns a query parameter value or a default value if none is set. |
||
49 | * |
||
50 | * @param string $key |
||
51 | * @param string $defaultValue (optional) |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getQueryParameter($key, $defaultValue = null) |
||
62 | |||
63 | /** |
||
64 | * Returns a body parameter value or a default value if none is set. |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @param string $defaultValue (optional) |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getBodyParameter($key, $defaultValue = null) |
||
78 | |||
79 | /** |
||
80 | * Returns a file value or a default value if none is set. |
||
81 | * |
||
82 | * @param string $key |
||
83 | * @param string $defaultValue (optional) |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getFile($key, $defaultValue = null) |
||
94 | |||
95 | /** |
||
96 | * Returns a cookie value or a default value if none is set. |
||
97 | * |
||
98 | * @param string $key |
||
99 | * @param string $defaultValue (optional) |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getCookie($key, $defaultValue = null) |
||
110 | |||
111 | /** |
||
112 | * Returns all parameters. |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | public function getParameters() |
||
120 | |||
121 | /** |
||
122 | * Returns all query parameters. |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | public function getQueryParameters() |
||
130 | |||
131 | /** |
||
132 | * Returns all body parameters. |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | public function getBodyParameters() |
||
140 | |||
141 | /** |
||
142 | + Returns raw values from the read-only stream that allows you to read raw data from the request body. |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getRawBodyParameters() |
||
150 | |||
151 | /** |
||
152 | * Returns a Cookie Iterator. |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | public function getCookies() |
||
160 | |||
161 | /** |
||
162 | * Returns a File Iterator. |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | public function getFiles() |
||
170 | |||
171 | /** |
||
172 | * The URI which was given in order to access this page |
||
173 | * |
||
174 | * @return string |
||
175 | * @throws MissingRequestMetaVariableException |
||
176 | */ |
||
177 | public function getUri() |
||
181 | |||
182 | /** |
||
183 | * Return just the path |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | public function getPath() |
||
191 | |||
192 | /** |
||
193 | * Which request method was used to access the page; |
||
194 | * i.e. 'GET', 'HEAD', 'POST', 'PUT'. |
||
195 | * |
||
196 | * @return string |
||
197 | * @throws MissingRequestMetaVariableException |
||
198 | */ |
||
199 | public function getMethod() |
||
203 | |||
204 | /** |
||
205 | * Contents of the Accept: header from the current request, if there is one. |
||
206 | * |
||
207 | * @return string |
||
208 | * @throws MissingRequestMetaVariableException |
||
209 | */ |
||
210 | public function getHttpAccept() |
||
214 | |||
215 | /** |
||
216 | * The address of the page (if any) which referred the user agent to the |
||
217 | * current page. |
||
218 | * |
||
219 | * @return string |
||
220 | * @throws MissingRequestMetaVariableException |
||
221 | */ |
||
222 | public function getReferer() |
||
223 | { |
||
224 | return $this->getServerVariable('HTTP_REFERER'); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * Content of the User-Agent header from the request, if there is one. |
||
229 | * |
||
230 | * @return string |
||
231 | * @throws MissingRequestMetaVariableException |
||
232 | */ |
||
233 | public function getUserAgent() |
||
237 | |||
238 | /** |
||
239 | * The IP address from which the user is viewing the current page. |
||
240 | * |
||
241 | * @return string |
||
242 | * @throws MissingRequestMetaVariableException |
||
243 | */ |
||
244 | public function getIpAddress() |
||
248 | |||
249 | /** |
||
250 | * Checks to see whether the current request is using HTTPS. |
||
251 | * |
||
252 | * @return boolean |
||
253 | */ |
||
254 | public function isSecure() |
||
260 | |||
261 | /** |
||
262 | * The query string, if any, via which the page was accessed. |
||
263 | * |
||
264 | * @return string |
||
265 | * @throws MissingRequestMetaVariableException |
||
266 | */ |
||
267 | public function getQueryString() |
||
271 | |||
272 | private function getServerVariable($key) |
||
280 | } |
||
281 |