Passed
Branch tests1.5 (e599bd)
by Wanderson
01:46
created

Data   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 11 4
1
<?php
2
3
namespace Win\Data;
4
5
/**
6
 * Dados
7
 */
8
abstract class Data {
9
10
	/**
11
	 * Retorna valor da sessão
12
	 * @param string $key Nome da configuração
13
	 * @param string $default Valor default, caso esta configuração esteja em branco
14
	 */
15
	public static function get($key, $default = '') {
16
		$keys = explode('.', $key);
17
		$config = static::getAll();
18
		foreach ($keys as $k) {
19
			if (is_array($config) && array_key_exists($k, $config)) {
20
				$config = $config[$k];
21
			} else {
22
				return $default;
23
			}
24
		}
25
		return $config;
26
	}
27
28
	/** @return mixed[] */
29
	abstract protected static function getAll();
30
31
	/**
32
	 * @param string $key
33
	 * @param mixed $value
34
	 */
35
	abstract public static function set($key, $value);
36
}
37