Session   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 41
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A popAll() 0 6 1
A pop() 0 6 1
A instance() 0 6 1
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
	 * Retorna instância de Session
16
	 * @param string $group
17
	 * @return static
18
	 */
19
	public static function instance($group = 'default')
20
	{
21
		$instance = new Session();
22
		$instance->data = &$_SESSION[$group];
23
24
		return $instance;
25
	}
26
27
	/**
28
	 * Retorna todas variáveis da sessão e limpa a sessão
29
	 * @return mixed[]
30
	 */
31
	public function popAll()
32
	{
33
		$values = $this->all();
34
		$this->clear();
35
36
		return $values;
37
	}
38
39
	/**
40
	 * Retorna a variável da sessão e a remove
41
	 * @param string $key
42
	 * @param mixed $default
43
	 * @return mixed
44
	 */
45
	public function pop($key, $default = '')
46
	{
47
		$value = $this->get($key, $default);
48
		$this->delete($key);
49
50
		return $value;
51
	}
52
}
53