Passed
Pull Request — master (#21)
by Wanderson
03:27
created

Session::instance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\Repositories;
4
5
use Win\Common\Traits\ArrayDotTrait;
6
7
/**
8
 * Variáveis de $_SESSION
9
 */
10
class Session
11
{
12
	use ArrayDotTrait;
13
14
	/**
15
	 * Cria referência da sessão
16
	 */
17
	public function __construct()
18
	{
19
		$this->data = &$_SESSION;
20
	}
21
22
	/**
23
	 * Retorna todas variáveis da sessão e limpa a sessão
24
	 * @return mixed[]
25
	 */
26
	public function popAll()
27
	{
28
		$values = $this->all();
29
		$this->clear();
30
31
		return $values;
32
	}
33
34
	/**
35
	 * Retorna a variável da sessão e a remove
36
	 * @param string $key
37
	 * @param mixed $default
38
	 * @return mixed
39
	 */
40
	public function pop($key, $default = '')
41
	{
42
		$value = $this->get($key, $default);
43
		$this->delete($key);
44
45
		return $value;
46
	}
47
}
48