Passed
Push — 1.11.x ( 253edb...02b7a3 )
by Angel Fernando Quiroz
10:08 queued 11s
created

Request::is_get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Provides access to various HTTP request elements: GET, POST, FILE, etc paramaters.
5
 * @license see /license.txt
6
 * @deprecated
7
 * @author Laurent Opprecht <[email protected]> for the Univesity of Geneva
8
 */
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
    }
59
60
}
61