AuraSessionStorage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 51
ccs 14
cts 14
cp 1
rs 10

5 Methods

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