Session::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
declare(strict_types=1);
7
8
namespace SocialConnect\Provider\Session;
9
10
class Session implements SessionInterface
11
{
12
    public function __construct()
13
    {
14
        if (session_status() == PHP_SESSION_NONE) {
15
            session_start();
16
        }
17
    }
18
19
    /**
20
     * @param string $key
21
     *
22
     * @return mixed
23
     */
24
    public function get($key)
25
    {
26
        if (isset($_SESSION[$key])) {
27
            return $_SESSION[$key];
28
        }
29
30
        return null;
31
    }
32
33
    /**
34
     * @param string $key
35
     * @param mixed $value
36
     */
37
    public function set($key, $value)
38
    {
39
        $_SESSION[$key] = $value;
40
    }
41
42
    /**
43
     * @param string $key
44
     */
45
    public function delete($key)
46
    {
47
        if (isset($_SESSION[$key])) {
48
            unset($_SESSION[$key]);
49
        }
50
    }
51
}
52