1 | <?php |
||
10 | class Request { |
||
11 | /** |
||
12 | * GET parameters |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $get = []; |
||
17 | |||
18 | /** |
||
19 | * POST parameters |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $post = []; |
||
24 | |||
25 | /** |
||
26 | * COOKIE parameters |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $cookie = []; |
||
31 | |||
32 | /** |
||
33 | * FILES parameters |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $files = []; |
||
38 | |||
39 | /** |
||
40 | * SERVER parameters |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $server = []; |
||
45 | |||
46 | /** |
||
47 | * Headers |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $headers = []; |
||
52 | |||
53 | /** |
||
54 | * Create a new instance from php superglobals |
||
55 | * |
||
56 | * @return Request |
||
57 | */ |
||
58 | 1 | public static function fromGlobals() { |
|
59 | 1 | return new static( stripslashes_deep( $_GET ), stripslashes_deep( $_POST ), $_COOKIE, $_FILES, $_SERVER, getallheaders() ); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Constructor |
||
64 | * |
||
65 | * @param array $get |
||
66 | * @param array $post |
||
67 | * @param array $cookie |
||
68 | * @param array $files |
||
69 | * @param array $server |
||
70 | * @param array $headers |
||
71 | */ |
||
72 | public function __construct( $get, $post, $cookie, $files, $server, $headers ) { |
||
80 | |||
81 | /** |
||
82 | * Return the request method |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 1 | public function getMethod() { |
|
96 | |||
97 | /** |
||
98 | * Return the request url |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 3 | public function getUrl() { |
|
112 | |||
113 | /** |
||
114 | * Return a value from any of the request parameters |
||
115 | * |
||
116 | * @see \CarbonFramework\Support\Arr |
||
117 | * @return mixed |
||
118 | */ |
||
119 | protected function input() { |
||
130 | |||
131 | /** |
||
132 | * Return a value from the GET parameters |
||
133 | * |
||
134 | * @see \CarbonFramework\Support\Arr |
||
135 | * @return mixed |
||
136 | */ |
||
137 | 3 | public function get() { |
|
140 | |||
141 | /** |
||
142 | * Return a value from the POST parameters |
||
143 | * |
||
144 | * @see \CarbonFramework\Support\Arr |
||
145 | * @return mixed |
||
146 | */ |
||
147 | public function post() { |
||
150 | |||
151 | /** |
||
152 | * Return a value from the COOKIE parameters |
||
153 | * |
||
154 | * @see \CarbonFramework\Support\Arr |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public function cookie() { |
||
160 | |||
161 | /** |
||
162 | * Return a value from the FILES parameters |
||
163 | * |
||
164 | * @see \CarbonFramework\Support\Arr |
||
165 | * @return mixed |
||
166 | */ |
||
167 | public function files() { |
||
170 | |||
171 | /** |
||
172 | * Return a value from the SERVER parameters |
||
173 | * |
||
174 | * @see \CarbonFramework\Support\Arr |
||
175 | * @return mixed |
||
176 | */ |
||
177 | public function server() { |
||
180 | |||
181 | /** |
||
182 | * Return a value from the headers |
||
183 | * |
||
184 | * @see \CarbonFramework\Support\Arr |
||
185 | * @return mixed |
||
186 | */ |
||
187 | public function headers() { |
||
190 | } |
||
191 |