ZendSessionStorage::clear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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