GlobalVariableGetter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 8 2
A get() 0 12 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