mageekguy\atoum\mock\php\method: lines coverage

84% of 121

OPs

92% of 24

Lines

73% of 15

Branches

82% of 11

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\mock\php\method::__construct() 11 100% 3 100% 1 0% 1 100%
mageekguy\atoum\mock\php\method::__toString() 25 100% 7 100% 4 100% 2 100%
mageekguy\atoum\mock\php\method::getArguments() 6 0% 1 0% 1 0% 1 0%
mageekguy\atoum\mock\php\method::getName() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\mock\php\method::isConstructor() 6 100% 1 100% 1 100% 1 100%
mageekguy\atoum\mock\php\method::returnReference() 23 96% 5 100% 4 75% 2 100%
mageekguy\atoum\mock\php\method::addArgument() 10 100% 2 100% 1 100% 1 100%
mageekguy\atoum\mock\php\method::getArgumentsAsString() 22 100% 3 100% 1 100% 1 100%
mageekguy\atoum\mock\php\method::get() 12 0% 1 0% 1 0% 1 0%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\mock\php;
4

                    
5
use
6
	mageekguy\atoum,
7
	mageekguy\atoum\exceptions
8
;
9

                    
10
class method
11
{
12
	protected $returnReference = false;
13
	protected $name = '';
14
	protected $isConstructor = false;
15
	protected $arguments = array();
16

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

                    
21
		$this->isConstructor = ($name == __FUNCTION__);
22
	}
23

                    
24
	public function __toString()100%
25
	{
26
		$string = 'public function ';
27

                    
28
		if ($this->returnReference === true)
29
		{
30
			$string .= '& ';
31
		}
32

                    
33
		$string .= $this->name . '(' . $this->getArgumentsAsString() . ')';
34

                    
35
		return $string;
36
	}
37

                    
38
	public function getArguments()0%
39
	{
40
		return $this->arguments;
41
	}
42

                    
43
	public function getName()100%
44
	{
45
		return $this->name;
46
	}
47

                    
48
	public function isConstructor()100%
49
	{
50
		return $this->isConstructor;
51
	}
52

                    
53
	public function returnReference()100%
54
	{
55
		if ($this->isConstructor === true)
56
		{
57
			throw new exceptions\logic('Constructor can not return a reference');
58
		}
59

                    
60
		$this->returnReference = true;
61

                    
62
		return $this;
63
	}
64

                    
65
	public function addArgument(method\argument $argument)100%
66
	{
67
		$this->arguments[] = $argument;
68

                    
69
		return $this;
70
	}
71

                    
72
	public function getArgumentsAsString()100%
73
	{
74
		$arguments = $this->arguments;
75

                    
76
		array_walk($arguments, function(& $value) { $value = (string) $value; });
77

                    
78
		return join(', ', $arguments);
79
	}
80

                    
81
	public static function get($name)0%
82
	{
83
		return new static($name);
84
	}
85
}