1 | <?php |
||
17 | class Environment implements EnvironmentInterface |
||
18 | { |
||
19 | /** |
||
20 | * Server environment data, must have same structure as $_SERVER superglobal. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | private $server; |
||
25 | |||
26 | /** |
||
27 | * Raw data from the request body. |
||
28 | * |
||
29 | * @var resource |
||
30 | */ |
||
31 | private $body; |
||
32 | |||
33 | /** |
||
34 | * An associative array constructed from cookies, must have same structure as $_COOKIE. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | private $cookies; |
||
39 | |||
40 | /** |
||
41 | * An associative array of uploaded items, must have same structure as $_FILES. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $files; |
||
46 | |||
47 | /** |
||
48 | * An associative array of variables passed to the current script via the HTTP POST method. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | private $post; |
||
53 | |||
54 | /** |
||
55 | * Constructor |
||
56 | * |
||
57 | * @param array $server An associative array containing information such as headers, paths, |
||
58 | * and script locations. Must have same structure as $_SERVER. |
||
59 | * @param resource $body Raw data from the request body. |
||
60 | * @param array $post An associative array of variables passed to the current script via the HTTP POST method. |
||
61 | * @param array $cookie An associative array constructed from cookies, must have same structure as $_COOKIE. |
||
62 | * @param array $files An associative array of uploaded items, must have same structure as $_FILES. |
||
63 | * |
||
64 | */ |
||
65 | 24 | public function __construct(array $server, $body, $post = [], $cookie = [], $files = []) |
|
77 | |||
78 | /** |
||
79 | * Get query string |
||
80 | * |
||
81 | * @return string|null query string |
||
82 | */ |
||
83 | 2 | public function getQueryString() |
|
87 | |||
88 | /** |
||
89 | * Get request method |
||
90 | * |
||
91 | * @return string|null |
||
92 | */ |
||
93 | 2 | public function getRequestMethod() |
|
97 | |||
98 | /** |
||
99 | * Get request uri |
||
100 | * |
||
101 | * @return string|null |
||
102 | */ |
||
103 | 2 | public function getRequestUri() |
|
107 | /** |
||
108 | * Get request scheme |
||
109 | * |
||
110 | * @return string|null |
||
111 | */ |
||
112 | 2 | public function getRequestScheme() |
|
116 | |||
117 | /** |
||
118 | * Get host |
||
119 | * |
||
120 | * @return string|null |
||
121 | */ |
||
122 | 2 | public function getHost() |
|
126 | |||
127 | /** |
||
128 | * Get port |
||
129 | * |
||
130 | * @return int|null |
||
131 | */ |
||
132 | 2 | public function getPort() |
|
136 | |||
137 | /** |
||
138 | * Get protocol version |
||
139 | * |
||
140 | * @return string|null |
||
141 | */ |
||
142 | 2 | public function getProtocolVersion() |
|
152 | |||
153 | /** |
||
154 | * Get auth user |
||
155 | * |
||
156 | * @return string|null |
||
157 | */ |
||
158 | 2 | public function getAuthUser() |
|
166 | |||
167 | /** |
||
168 | * Get auth password |
||
169 | * |
||
170 | * @return string|null |
||
171 | */ |
||
172 | 2 | public function getAuthPassword() |
|
180 | |||
181 | /** |
||
182 | * Get body |
||
183 | * |
||
184 | * @return resource |
||
185 | */ |
||
186 | 1 | public function getBody() |
|
190 | |||
191 | /** |
||
192 | * Get body |
||
193 | * |
||
194 | * @return resource |
||
195 | */ |
||
196 | 1 | public function getPost() |
|
200 | |||
201 | /** |
||
202 | * Get cookies |
||
203 | * |
||
204 | * @return array |
||
205 | */ |
||
206 | 1 | public function getCookies() |
|
210 | |||
211 | /** |
||
212 | * Get files |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | 1 | public function getFiles() |
|
220 | |||
221 | /** |
||
222 | * Get server |
||
223 | * |
||
224 | * @return array |
||
225 | */ |
||
226 | 1 | public function getServer() |
|
230 | } |
||
231 |