-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRequest.php
More file actions
49 lines (37 loc) · 951 Bytes
/
Request.php
File metadata and controls
49 lines (37 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Hiro;
class Request
{
private $currentUri;
private $get = [];
private $post = [];
public function __construct() {
$this->currentUri = $_SERVER['REQUEST_URI'];
foreach($_GET as $key => $item) {
$this->get[$key] = $item;
}
foreach($_POST as $key => $item) {
$this->post[$key] = $item;
}
}
public function get($key, $default = '') {
if (!isset($this->get[$key])) {
return $default;
}
return $this->get[$key];
}
public function post($key, $default = '') {
if (!isset($this->post[$key])) {
return $default;
}
return $this->post[$key];
}
public function getCurrentUri()
{
return $this->currentUri;
}
public function getMethod()
{
return strtolower($_SERVER['REQUEST_METHOD']);
}
}