| Total Complexity | 11 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Request |
||
| 10 | { |
||
| 11 | |||
| 12 | public static function get($key, $default = null) |
||
| 13 | { |
||
| 14 | return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default; |
||
| 15 | } |
||
| 16 | |||
| 17 | public static function has($key) { |
||
| 18 | return isset($_REQUEST[$key]); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Returns true if the request is a GET request. False otherwise. |
||
| 23 | * |
||
| 24 | * @return bool |
||
| 25 | */ |
||
| 26 | public static function is_get() |
||
| 27 | { |
||
| 28 | $method = self::server()->request_method(); |
||
| 29 | $method = strtoupper($method); |
||
| 30 | return $method == 'GET'; |
||
| 31 | } |
||
| 32 | |||
| 33 | public static function post($key, $default = null) |
||
| 34 | { |
||
| 35 | return isset($_POST[$key]) ? $_POST[$key] : $default; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Returns true if the request is a POST request. False otherwise. |
||
| 40 | * |
||
| 41 | * @return bool |
||
| 42 | */ |
||
| 43 | public static function is_post() |
||
| 44 | { |
||
| 45 | $method = self::server()->request_method(); |
||
| 46 | $method = strtoupper($method); |
||
| 47 | return $method == 'POST'; |
||
| 48 | } |
||
| 49 | |||
| 50 | static function file($key, $default = null) |
||
| 51 | { |
||
| 52 | return isset($_FILES[$key]) ? $_FILES[$key] : $default; |
||
| 53 | } |
||
| 54 | |||
| 55 | static function environment($key, $default = null) |
||
| 56 | { |
||
| 57 | return isset($_ENV[$key]) ? $_ENV[$key] : $default; |
||
| 58 | } |
||
| 61 |