1 | <?php |
||
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 | public static function has($name) |
||
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 | public static function get($name) |
||
47 | } |
||
48 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: