mageekguy\atoum\superglobals: lines coverage

91% of 161

OPs

97% of 38

Lines

92% of 62

Branches

91% of 22

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\superglobals::__set() 15 100% 2 100% 1 0% 1 100%
mageekguy\atoum\superglobals::__get() 89 87% 23 96% 31 94% 11 91%
mageekguy\atoum\superglobals::check() 57 96% 13 100% 30 93% 10 90%
#
1
<?php
2

                    
3
namespace mageekguy\atoum;
4

                    
5
use
6
	mageekguy\atoum\exceptions
7
;
8

                    
9
class superglobals
10
{
11
	protected $superglobals = array();
12

                    
13
	public function __set($superglobal, $value)100%
14
	{
15
		$this->check($superglobal)->superglobals[$superglobal] = $value;
16
	}
17

                    
18
	public function & __get($superglobal)96%
19
	{
20
		$this->check($superglobal);
21

                    
22
		if (array_key_exists($superglobal, $this->superglobals) === true)
23
		{
24
			return $this->superglobals[$superglobal];
25
		}
26
		else switch ($superglobal)
27
		{
28
			case 'GLOBALS':
29
				return $GLOBALS;
30

                    
31
			case '_SERVER':
32
				return $_SERVER;
33

                    
34
			case '_GET':
35
				return $_GET;
36

                    
37
			case '_POST':
38
				return $_POST;
39

                    
40
			case '_FILES':
41
				return $_FILES;
42

                    
43
			case '_COOKIE':
44
				return $_COOKIE;
45

                    
46
			case '_SESSION':
47
				return $_SESSION;
48

                    
49
			case '_REQUEST':
50
				return $_REQUEST;
51

                    
52
			case '_ENV':
53
				return $_ENV;
54
		}
55
	}
56

                    
57
	protected function check($superglobal)100%
58
	{
59
		switch ($superglobal)
60
		{
61
			case 'GLOBALS':
62
			case '_SERVER':
63
			case '_GET':
64
			case '_POST':
65
			case '_FILES':
66
			case '_COOKIE':
67
			case '_SESSION':
68
			case '_REQUEST':
69
			case '_ENV':
70
				return $this;
71

                    
72
			default:
73
				throw new exceptions\logic\invalidArgument('PHP superglobal \'$' . $superglobal . '\' does not exist');
74
		}
75
	}
76
}