Passed
Push — develop ( 63f05f...0005e4 )
by Mathieu
01:40
created

Native   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 49
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A loadSession() 0 4 2
A read() 0 5 2
A write() 0 4 1
A __construct() 0 5 1
A destroy() 0 4 1
A regenerate() 0 3 1
A getId() 0 3 1
A close() 0 3 1
1
<?php declare(strict_types=1);
2
namespace Suricate\Session;
3
4
class Native extends \Suricate\Session
5
{
6 1
    public function __construct()
7
    {
8 1
        parent::__construct();
9
10 1
        $this->loadSession();
11 1
    }
12
13 4
    private function loadSession()
14
    {
15 4
        if (session_id() == '') {
16 2
            session_start();
17
        }
18 4
    }
19
20 1
    public function getId()
21
    {
22 1
        return session_id();
23
    }
24
25 1
    public function regenerate()
26
    {
27 1
        return session_regenerate_id();
28
    }
29
30 4
    public function read($key)
31
    {
32 4
        $this->loadSession();
33 4
        if (isset($_SESSION[$key])) {
34 4
            return $_SESSION[$key];
35
        }
36 4
    }
37
38 4
    public function write($key, $data)
39
    {
40 4
        $this->loadSession();
41 4
        $_SESSION[$key] = $data;
42 4
    }
43
44 4
    public function destroy($key)
45
    {
46 4
        $this->loadSession();
47 4
        unset($_SESSION[$key]);
48 4
    }
49
50 1
    public function close()
51
    {
52 1
        session_destroy();
53 1
    }
54
}
55