Completed
Push — master ( 466d8a...4a1721 )
by Adam
04:54
created

Session   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 47
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 4 1
A get() 0 4 2
A clear() 0 4 1
A clearAll() 0 4 1
1
<?php
2
/**
3
 * SessionStorage.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:ConfirmationDialog!
9
 * @subpackage     Storage
10
 * @since          1.0.0
11
 *
12
 * @date           08.06.14
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\ConfirmationDialog\Storage;
18
19
use Nette;
20
use Nette\Http;
21
22
/**
23
 * Confirmer session status storage
24
 *
25
 * @package        iPublikuj:ConfirmationDialog!
26
 * @subpackage     Storage
27
 *
28
 * @author         Adam Kadlec <[email protected]>
29
 */
30 1
final class Session implements IStorage
31
{
32
	/**
33
	 * @var Http\SessionSection
34
	 */
35
	private $session;
36
37
	/**
38
	 * @param Http\Session $session
39
	 */
40
	public function __construct(Http\Session $session)
41
	{
42 1
		$this->session = $session->getSection('ipub.confirmation-dialog');
43 1
	}
44
45
	/**
46
	 * {@inheritdoc}
47
	 */
48
	public function set(string $key, $value) : void
49
	{
50 1
		$this->session->$key = $value;
51 1
	}
52
53
	/**
54
	 * {@inheritdoc}
55
	 */
56
	public function get(string $key, $default = FALSE)
57
	{
58 1
		return isset($this->session->$key) ? $this->session->$key : $default;
59
	}
60
61
	/**
62
	 * {@inheritdoc}
63
	 */
64
	public function clear(string $key) : void
65
	{
66 1
		unset($this->session->$key);
67 1
	}
68
69
	/**
70
	 * {@inheritdoc}
71
	 */
72
	public function clearAll() : void
73
	{
74
		$this->session->remove();
75
	}
76
}
77