ZendSessionStorage   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 58
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A store() 0 4 1
A read() 0 7 2
A exists() 0 4 1
A clear() 0 4 1
1
<?php
2
namespace Golem\Auth\Storage;
3
4
5
class ZendSessionStorage implements StorageInterface
6
{
7
    /**
8
     * @var \Zend\Session\Container
9
     */
10
    private $session;
11
12
    /**
13
     * @var string
14
     */
15
    private $namespace;
16
17
    /**
18
     * AuraSessionStorage constructor.
19
     * @param \Zend\Session\Container $session
20
     * @param string $namespace
21
     */
22 4
    public function __construct(\Zend\Session\Container $session, $namespace = 'golem_auth')
23
    {
24 4
        $this->session = $session;
25 4
        $this->namespace = $namespace;
26 4
    }
27
    /**
28
     * @param string|int $id
29
     * @return void
30
     */
31 3
    public function store($id)
32
    {
33 3
        $this->session[$this->namespace] = $id;
34 3
    }
35
36
    /**
37
     * @return string|int
38
     */
39 2
    public function read()
40
    {
41 2
        if (!$this->exists()) {
42 1
            return null;
43
        }
44 1
        return $this->session[$this->namespace];
45
    }
46
47
    /**
48
     * @return bool
49
     */
50 4
    public function exists()
51
    {
52 4
        return isset($this->session[$this->namespace]);
53
    }
54
55
    /**
56
     * Clears out identity
57
     */
58 1
    public function clear()
59
    {
60 1
        unset($this->session[$this->namespace]);
61 1
    }
62
}
63