1 | <?php |
||
5 | class Emulate { |
||
6 | |||
7 | private static $egpcs = array( |
||
8 | 'ENV', 'GET', 'POST', 'COOKIE', 'SERVER', 'SESSION', 'FILES' |
||
9 | ); |
||
10 | |||
11 | /** |
||
12 | * Emula a variavel de ambiente $_ENV |
||
13 | * |
||
14 | * @return boolean |
||
15 | */ |
||
16 | public static function env() { |
||
23 | |||
24 | /** |
||
25 | * Emula: register_long_arrays = On |
||
26 | * |
||
27 | * @return boolean |
||
28 | */ |
||
29 | public static function registerLongArrays() { |
||
36 | |||
37 | /** |
||
38 | * Emula: register_globals = On |
||
39 | * |
||
40 | * @return boolean |
||
41 | */ |
||
42 | public static function registerGlobals() { |
||
59 | |||
60 | /** |
||
61 | * Emula: magic_quotes_gpc = On|Off |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public static function magicQuotesGPCR($directive = 'On') { |
||
87 | |||
88 | /** |
||
89 | * Emula o comportamento do session_register |
||
90 | * @static |
||
91 | * @link http://php.net/manual/pt_BR/function.session-register.php |
||
92 | */ |
||
93 | public static function sessionRegister() { |
||
101 | |||
102 | /** |
||
103 | * Emula o comportamento da função session_is_registered |
||
104 | * |
||
105 | * @link http://php.net/manual/pt_BR/function.session-is-registered.php |
||
106 | * @static |
||
107 | * @param mixed $key |
||
108 | */ |
||
109 | public static function sessionIsRegistered($key) { |
||
110 | return array_key_exists($key, $_SESSION); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Emula o comportamento da função sesion_unregister |
||
115 | * |
||
116 | * @link http://php.net/manual/pt_BR/function.session-unregister.php |
||
117 | * @static |
||
118 | * @param mixed $key |
||
119 | */ |
||
120 | public static function sessionUnregister($key) { |
||
123 | } |
||
124 |
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: