GlobalVariableGetter::get()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Happyr\LinkedIn\Http;
4
5
/**
6
 * Look in $_REQUEST and $_GET if there is a variable we want.
7
 *
8
 * @author Tobias Nyholm <[email protected]>
9
 */
10
class GlobalVariableGetter
11
{
12
    /**
13
     * Returns true iff the $_REQUEST or $_GET variables has a key with $name.
14
     *
15
     * @param string $name
16
     *
17
     * @return bool
18
     */
19 7
    public static function has($name)
20
    {
21 7
        if (isset($_REQUEST[$name])) {
22 3
            return true;
23
        }
24
25 4
        return isset($_GET[$name]);
26
    }
27
28
    /**
29
     * Returns the value in $_REQUEST[$name] or $_GET[$name] if the former was empty. If no value found, return null.
30
     *
31
     * @param string $name
32
     *
33
     * @return mixed|null
34
     */
35 5
    public static function get($name)
36
    {
37 5
        if (isset($_REQUEST[$name])) {
38 3
            return $_REQUEST[$name];
39
        }
40
41 2
        if (isset($_GET[$name])) {
42 2
            return $_GET[$name];
43
        }
44
45 1
        return;
46
    }
47
}
48