1 | <?php |
||
5 | class Request implements RequestInterface |
||
6 | { |
||
7 | /** |
||
8 | * @param string $uri The request URI. |
||
9 | */ |
||
10 | protected $uri; |
||
11 | |||
12 | |||
13 | /** |
||
14 | * @param array $uriComponents An array of components that make up the URI. |
||
15 | */ |
||
16 | protected $uriComponents; |
||
17 | |||
18 | |||
19 | /** |
||
20 | * @param string $method The request method. |
||
21 | */ |
||
22 | protected $method; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * @var array $requestData An array of request data (from POST, PUT, etc). |
||
27 | */ |
||
28 | protected $requestData; |
||
29 | |||
30 | |||
31 | /** |
||
32 | * @var array $queryData An array of query data (i.e. a GET request). |
||
33 | */ |
||
34 | protected $queryData; |
||
35 | |||
36 | |||
37 | /** |
||
38 | * @var array $serverData An array of server data (i.e. HTTP_REFERER, DOC_ROOT etc). |
||
39 | */ |
||
40 | protected $serverData; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * @var array $cookies An array of cookies the current request holds |
||
45 | */ |
||
46 | protected $cookies; |
||
47 | |||
48 | |||
49 | /** |
||
50 | * @var array $fileData An array of file data. |
||
51 | */ |
||
52 | protected $fileData; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Class constructor. |
||
57 | * |
||
58 | * @param string $uri The request URI. |
||
59 | * @param string $method The request method. |
||
60 | * @param array $requestData The request data. |
||
61 | * @param array $queryData The query data. |
||
62 | * @param array $serverData The server data. |
||
63 | * @param array $cookies The cookies for the current request |
||
64 | * @param array $fileData An array of file data. |
||
65 | * @throws \InvalidArgumentException |
||
66 | */ |
||
67 | public function __construct( |
||
94 | |||
95 | |||
96 | /** |
||
97 | * Get the request method. |
||
98 | * |
||
99 | * @return string The request method. |
||
100 | */ |
||
101 | public function getMethod() |
||
105 | |||
106 | |||
107 | /** |
||
108 | * Get the URI. |
||
109 | * |
||
110 | * @return string The URI. |
||
111 | */ |
||
112 | public function getUri() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * Get the URI path. |
||
120 | * |
||
121 | * @return string The URI path. |
||
122 | */ |
||
123 | public function getUriPath() |
||
127 | |||
128 | |||
129 | /** |
||
130 | * Get the request data. |
||
131 | * |
||
132 | * @return array The request data. |
||
133 | */ |
||
134 | public function getRequestData() |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Get the query data. |
||
142 | * |
||
143 | * @return array The query data. |
||
144 | */ |
||
145 | public function getQueryData() |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Get the server data. |
||
153 | * |
||
154 | * @return array The server data. |
||
155 | */ |
||
156 | public function getServerData() |
||
160 | |||
161 | |||
162 | /** |
||
163 | * Get the HTTP REFERER from the server data. |
||
164 | * |
||
165 | * @return string|null The referer or null if not found. |
||
166 | */ |
||
167 | public function getReferer() |
||
177 | |||
178 | |||
179 | /** |
||
180 | * Get file data. |
||
181 | * |
||
182 | * @return array File data. |
||
183 | */ |
||
184 | public function getFileData() |
||
188 | |||
189 | |||
190 | /** |
||
191 | * Add data to the request. |
||
192 | * |
||
193 | * @param array $data An array of data. |
||
194 | */ |
||
195 | public function addRequestData(array $data) |
||
199 | |||
200 | |||
201 | /** |
||
202 | * @return bool Whether the method is post or not. |
||
203 | */ |
||
204 | public function isPost() |
||
208 | |||
209 | |||
210 | /** |
||
211 | * @return bool Whether the method is get or not. |
||
212 | */ |
||
213 | public function isGet() |
||
217 | |||
218 | |||
219 | /** |
||
220 | * Get cookie value by name |
||
221 | * |
||
222 | * @param string $name |
||
223 | * |
||
224 | * @return string|null returns the cookie value for the index name provided |
||
225 | */ |
||
226 | public function getCookie($name) |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Returns true if the cookie is set for the name provided else false |
||
234 | * |
||
235 | * @param string @name |
||
236 | * |
||
237 | * @return boolean |
||
238 | */ |
||
239 | public function issetCookie($name) |
||
243 | } |
||
244 |