Globals   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 9
eloc 21
c 1
b 0
f 1
dl 0
loc 65
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getGET() 0 6 2
A getPOST() 0 6 2
A getSERVER() 0 6 2
A getSESSION() 0 6 2
1
<?php
2
3
namespace Core\Services\Globals;
4
5
class Globals
6
{
7
    private $GET;
8
    private $POST;
9
    private $SERVER;
10
    private $SESSION;
11
12
    public function __construct()
13
    {
14
        $this->GET = \filter_input_array(\INPUT_GET) ?? \null;
15
        $this->POST = \filter_input_array(\INPUT_POST) ?? \null;
16
        $this->SERVER = \filter_input_array(\INPUT_SERVER) ?? \null;
17
        $this->SESSION = \filter_var_array($_SESSION, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
0 ignored issues
show
Bug introduced by
The constant Core\Services\Globals\FI...TIZE_FULL_SPECIAL_CHARS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
18
    }
19
20
    /**
21
     * Get $_GET
22
     * @param string $key
23
     * @return mixed
24
     */
25
    public function getGET(string $key = \null)
26
    {
27
        if (null !== $key) {
28
            return $this->GET[$key] ?? \null;
29
        }
30
        return $this->GET;
31
    }
32
33
    /**
34
     * Get $_POST
35
     * @param string $key
36
     * @return mixed
37
     */
38
    public function getPOST(string $key = \null)
39
    {
40
        if (null !== $key) {
41
            return $this->POST[$key] ?? \null;
42
        }
43
        return $this->POST;
44
    }
45
46
    /**
47
     * Get $_SERVER
48
     * @param string $key
49
     * @return mixed
50
     */
51
    public function getSERVER(string $key = \null)
52
    {
53
        if (null !== $key) {
54
            return $this->SERVER[$key] ?? \null;
55
        }
56
        return $this->SERVER;
57
    }
58
59
    /**
60
     * Get $_SESSION
61
     * @param string $key
62
     * @return mixed
63
     */
64
    public function getSESSION(string $key = \null)
65
    {
66
        if (null !== $key) {
67
            return $this->SESSION[$key] ?? \null;
68
        }
69
        return $this->SESSION;
70
    }
71
}
72