mageekguy\atoum\scripts\treemap\categorizer: lines coverage

99% of 123

OPs

100% of 18

Lines

85% of 13

Branches

100% of 11

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\scripts\treemap\categorizer::__construct() 12 100% 3 100% 1 0% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::getName() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::setCallback() 12 100% 2 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::getCallback() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::setMinDepthColor() 15 100% 2 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::getMinDepthColor() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::setMaxDepthColor() 15 100% 2 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::getMaxDepthColor() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::categorize() 14 100% 1 100% 1 100% 1 100%
mageekguy\atoum\scripts\treemap\categorizer::checkColor() 31 97% 4 100% 4 75% 2 100%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\scripts\treemap;
4

                    
5
use
6
	mageekguy\atoum\exceptions
7
;
8

                    
9
class categorizer
10
{
11
	protected $name = '';
12
	protected $callback = null;
13
	protected $minDepthColor = '#94ff5a';
14
	protected $maxDepthColor = '#00500f';
15

                    
16
	public function __construct($name)100%
17
	{
18
		$this->name = $name;
19

                    
20
		$this->setCallback();
21
	}
22

                    
23
	public function getName()100%
24
	{
25
		return $this->name;
26
	}
27

                    
28
	public function setCallback(\closure $callback = null)100%
29
	{
30
		$this->callback = $callback ?: function() { return false; };
31

                    
32
		return $this;
33
	}
34

                    
35
	public function getCallback()100%
36
	{
37
		return $this->callback;
38
	}
39

                    
40
	public function setMinDepthColor($color)100%
41
	{
42
		$this->minDepthColor = static::checkColor($color);
43

                    
44
		return $this;
45
	}
46

                    
47
	public function getMinDepthColor()100%
48
	{
49
		return $this->minDepthColor;
50
	}
51

                    
52
	public function setMaxDepthColor($color)100%
53
	{
54
		$this->maxDepthColor = static::checkColor($color);
55

                    
56
		return $this;
57
	}
58

                    
59
	public function getMaxDepthColor()100%
60
	{
61
		return $this->maxDepthColor;
62
	}
63

                    
64
	public function categorize(\splFileInfo $file)100%
65
	{
66
		return call_user_func_array($this->callback, array($file));
67
	}
68

                    
69
	protected static function checkColor($color)100%
70
	{
71
		if (preg_match('/^#?[a-f0-9]{6}$/i', $color) === 0)
72
		{
73
			throw new exceptions\logic\invalidArgument('Color must be in hexadecimal format');
74
		}
75

                    
76
		return '#' . ltrim($color, '#');
77
	}
78
}