AuraSessionStorage::store()   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 1
crap 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