Completed
Push — master ( bda8d5...d74c6d )
by Дмитрий
03:32 queued 01:52
created

Session   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 9
dl 0
loc 39
rs 10
c 2
b 0
f 0
ccs 0
cts 14
cp 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 3 1
A __construct() 0 4 2
A delete() 0 4 2
A get() 0 7 2
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace SocialConnect\Provider\Session;
7
8
class Session implements SessionInterface
9
{
10
    public function __construct()
11
    {
12
        if (session_status() == PHP_SESSION_NONE) {
13
            session_start();
14
        }
15
    }
16
17
    /**
18
     * @param string $key
19
     *
20
     * @return mixed
21
     */
22
    public function get($key)
23
    {
24
        if (isset($_SESSION[$key])) {
25
            return $_SESSION[$key];
26
        }
27
28
        return null;
29
    }
30
31
    /**
32
     * @param string $key
33
     * @param mixed $value
34
     */
35
    public function set($key, $value)
36
    {
37
        $_SESSION[$key] = $value;
38
    }
39
40
    /**
41
     * @param string $key
42
     */
43
    public function delete($key)
44
    {
45
        if (isset($_SESSION[$key])) {
46
            unset($_SESSION[$key]);
47
        }
48
    }
49
}
50