mageekguy\atoum\locale: lines coverage

100% of 121

OPs

100% of 16

Lines

95% of 21

Branches

100% of 11

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\locale::__construct() 15 100% 5 100% 4 75% 2 100%
mageekguy\atoum\locale::__toString() 13 100% 1 100% 5 100% 2 100%
mageekguy\atoum\locale::set() 10 100% 2 100% 1 100% 1 100%
mageekguy\atoum\locale::get() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\locale::_() 23 100% 1 100% 1 100% 1 100%
mageekguy\atoum\locale::__() 30 100% 1 100% 5 100% 2 100%
mageekguy\atoum\locale::format() 24 100% 5 100% 4 100% 2 100%
#
1
<?php
2

                    
3
namespace mageekguy\atoum;
4

                    
5
class locale
6
{
7
	protected $value = null;
8

                    
9
	public function __construct($value = null)100%
10
	{
11
		if ($value !== null)
12
		{
13
			$this->set($value);
14
		}
15
	}
16

                    
17
	public function __toString()100%
18
	{
19
		return ($this->value === null ? 'unknown' : $this->value);
20
	}
21

                    
22
	public function set($value)100%
23
	{
24
		$this->value = (string) $value;
25

                    
26
		return $this;
27
	}
28

                    
29
	public function get()100%
30
	{
31
		return $this->value;
32
	}
33

                    
34
	public function _($string)100%
35
	{
36
		return self::format($string, array_slice(func_get_args(), 1));
37
	}
38

                    
39
	public function __($singular, $plural, $quantity)100%
40
	{
41
		return self::format($quantity <= 1 ? $singular : $plural, array_slice(func_get_args(), 3));
42
	}
43

                    
44
	private static function format($string, $arguments)100%
45
	{
46
		if (sizeof($arguments) > 0)
47
		{
48
			$string = vsprintf($string, $arguments);
49
		}
50

                    
51
		return $string;
52
	}
53
}