Globals::getSESSION()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 1
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