Completed
Push — master ( b6d929...8faf3c )
by Adam
12:18
created

Session::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
final class Session implements IStorage
23
{
24
	/**
25
	 * Define class name
26
	 */
27
	const CLASS_NAME = __CLASS__;
28
29
	/**
30
	 * @var Http\SessionSection
31
	 */
32
	private $session;
33
34
	/**
35
	 * @param Http\Session $session
36
	 */
37
	public function __construct(Http\Session $session)
38
	{
39
		$this->session = $session->getSection('ipub.confirmation-dialog');
40
	}
41
42
	/**
43
	 * {@inheritdoc}
44
	 */
45
	public function set(string $key, $value)
46
	{
47
		$this->session->$key = $value;
48
	}
49
50
	/**
51
	 * {@inheritdoc}
52
	 */
53
	public function get(string $key, $default = FALSE)
54
	{
55
		return isset($this->session->$key) ? $this->session->$key : $default;
56
	}
57
58
	/**
59
	 * {@inheritdoc}
60
	 */
61
	public function clear(string $key)
62
	{
63
		unset($this->session->$key);
64
	}
65
66
	/**
67
	 * {@inheritdoc}
68
	 */
69
	public function clearAll()
70
	{
71
		$this->session->remove();
72
	}
73
}
74