Session   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 52
ccs 9
cts 11
cp 0.8182
rs 10

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        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
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
	 * Implement nette smart magic
34
	 */
35 1
	use Nette\SmartObject;
36
37
	/**
38
	 * @var Http\SessionSection
39
	 */
40
	private $session;
41
42
	/**
43
	 * @param Http\Session $session
44
	 */
45
	public function __construct(Http\Session $session)
46
	{
47 1
		$this->session = $session->getSection('ipub.confirmation-dialog');
48 1
	}
49
50
	/**
51
	 * {@inheritdoc}
52
	 */
53
	public function set(string $key, $value) : void
54
	{
55 1
		$this->session->$key = $value;
56 1
	}
57
58
	/**
59
	 * {@inheritdoc}
60
	 */
61
	public function get(string $key, $default = FALSE)
62
	{
63 1
		return isset($this->session->$key) ? $this->session->$key : $default;
64
	}
65
66
	/**
67
	 * {@inheritdoc}
68
	 */
69
	public function clear(string $key) : void
70
	{
71 1
		unset($this->session->$key);
72 1
	}
73
74
	/**
75
	 * {@inheritdoc}
76
	 */
77
	public function clearAll() : void
78
	{
79
		$this->session->remove();
80
	}
81
}
82