Total Complexity | 12 |
Total Lines | 75 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class Session implements SessionInterface |
||
16 | { |
||
17 | /** |
||
18 | * @param string $key |
||
19 | * @param string|null $subKey |
||
20 | * @return mixed |
||
21 | */ |
||
22 | public function get(string $key, string $subKey = null) |
||
23 | { |
||
24 | return ($subKey === null) ? $_SESSION[$key] : $_SESSION[$key][$subKey]; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param string $key |
||
29 | * @param $value |
||
30 | * @param string|null $subKey |
||
31 | */ |
||
32 | public function set(string $key, $value, string $subKey = null): void |
||
33 | { |
||
34 | if (empty($subKey)) { |
||
35 | $_SESSION[$key] = $value; |
||
36 | return; |
||
37 | } |
||
38 | |||
39 | if ($subKey == 'increment') { |
||
40 | $_SESSION[$key][] = $value; |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | $_SESSION[$key][$subKey] = $value; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $key |
||
49 | * @param string|null $subKey |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function has(string $key, string $subKey = null): bool |
||
53 | { |
||
54 | return empty($subKey) ? isset($_SESSION[$key]) : isset($_SESSION[$key][$subKey]); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param string $key |
||
59 | * @param string|null $subKey |
||
60 | */ |
||
61 | public function unset(string $key, string $subKey = null): void |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @codeCoverageIgnore |
||
73 | */ |
||
74 | public function start(): void |
||
75 | { |
||
76 | session_start(); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @codeCoverageIgnore |
||
81 | */ |
||
82 | public function stop(): void |
||
83 | { |
||
84 | session_destroy(); |
||
85 | } |
||
86 | |||
87 | public function clear(): void |
||
90 | } |
||
91 | } |
||
92 |