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 | * Constructor |
||
49 | * |
||
50 | * @param array $server An associative array containing information such as headers, paths, |
||
51 | * and script locations. Must have same structure as $_SERVER. |
||
52 | * @param resource $body Raw data from the request body. |
||
53 | * @param array $cookie An associative array constructed from cookies, must have same structure as $_COOKIE. |
||
54 | * @param array $files An associative array of uploaded items, must have same structure as $_FILES. |
||
55 | * |
||
56 | */ |
||
57 | 23 | public function __construct(array $server, $body, $cookie = [], $files = []) |
|
68 | |||
69 | /** |
||
70 | * Get query string |
||
71 | * |
||
72 | * @return string|null query string |
||
73 | */ |
||
74 | 2 | public function getQueryString() |
|
78 | |||
79 | /** |
||
80 | * Get request method |
||
81 | * |
||
82 | * @return string|null |
||
83 | */ |
||
84 | 2 | public function getRequestMethod() |
|
88 | |||
89 | /** |
||
90 | * Get request uri |
||
91 | * |
||
92 | * @return string|null |
||
93 | */ |
||
94 | 2 | public function getRequestUri() |
|
98 | /** |
||
99 | * Get request scheme |
||
100 | * |
||
101 | * @return string|null |
||
102 | */ |
||
103 | 2 | public function getRequestScheme() |
|
107 | |||
108 | /** |
||
109 | * Get host |
||
110 | * |
||
111 | * @return string|null |
||
112 | */ |
||
113 | 2 | public function getHost() |
|
117 | |||
118 | /** |
||
119 | * Get port |
||
120 | * |
||
121 | * @return int|null |
||
122 | */ |
||
123 | 2 | public function getPort() |
|
127 | |||
128 | /** |
||
129 | * Get protocol version |
||
130 | * |
||
131 | * @return string|null |
||
132 | */ |
||
133 | 2 | public function getProtocolVersion() |
|
143 | |||
144 | /** |
||
145 | * Get auth user |
||
146 | * |
||
147 | * @return string|null |
||
148 | */ |
||
149 | 2 | public function getAuthUser() |
|
157 | |||
158 | /** |
||
159 | * Get auth password |
||
160 | * |
||
161 | * @return string|null |
||
162 | */ |
||
163 | 2 | public function getAuthPassword() |
|
171 | |||
172 | /** |
||
173 | * Get body |
||
174 | * |
||
175 | * @return resource |
||
176 | */ |
||
177 | 1 | public function getBody() |
|
181 | |||
182 | /** |
||
183 | * Get cookies |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | 1 | public function getCookies() |
|
191 | |||
192 | /** |
||
193 | * Get files |
||
194 | * |
||
195 | * @return array |
||
196 | */ |
||
197 | 1 | public function getFiles() |
|
201 | |||
202 | /** |
||
203 | * Get server |
||
204 | * |
||
205 | * @return array |
||
206 | */ |
||
207 | 1 | public function getServer() |
|
211 | } |
||
212 |