87% of 142OPs |
100% of 23Lines |
77% of 26Branches |
59% of 17Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\mock\controller\iterator::__construct() | 15 | 100% | 5 | 100% | 4 | 75% | 2 | 100% |
mageekguy\atoum\mock\controller\iterator::__set() | 24 | 67% | 4 | 100% | 6 | 50% | 3 | 0% |
mageekguy\atoum\mock\controller\iterator::getIterator() | 15 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\mock\controller\iterator::setMockController() | 9 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\mock\controller\iterator::getMockController() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\mock\controller\iterator::getMethods() | 48 | 77% | 5 | 100% | 10 | 80% | 6 | 33% |
mageekguy\atoum\mock\controller\iterator::addFilter() | 10 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\mock\controller\iterator::getFilters() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\mock\controller\iterator::resetFilters() | 9 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\mock\controller; |
4 |
|
5 |
use |
6 |
mageekguy\atoum\mock |
7 |
; |
8 |
|
9 |
class iterator implements \iteratorAggregate |
10 |
{ |
11 |
protected $controller = null; |
12 |
protected $filters = array(); |
13 |
|
14 |
public function __construct(mock\controller $controller = null)100% |
15 |
{ |
16 |
if ($controller != null) |
17 |
{ |
18 |
$this->setMockController($controller); |
19 |
} |
20 |
} |
21 |
|
22 |
public function __set($keyword, $mixed)100% |
23 |
{ |
24 |
foreach ($this->getMethods() as $method) |
25 |
{ |
26 |
$this->controller->{$method}->{$keyword} = $mixed; |
27 |
} |
28 |
|
29 |
return $this; |
30 |
} |
31 |
|
32 |
public function getIterator()100% |
33 |
{ |
34 |
return new \arrayIterator($this->getMethods()); |
35 |
} |
36 |
|
37 |
public function setMockController(mock\controller $controller)100% |
38 |
{ |
39 |
$this->controller = $controller; |
40 |
|
41 |
return $this; |
42 |
} |
43 |
|
44 |
public function getMockController()100% |
45 |
{ |
46 |
return $this->controller; |
47 |
} |
48 |
|
49 |
public function getMethods()100% |
50 |
{ |
51 |
$methods = ($this->controller === null ? array() : $this->controller->getMethods()); |
52 |
|
53 |
foreach ($this->filters as $filter) |
54 |
{ |
55 |
$methods = array_filter($methods, $filter); |
56 |
} |
57 |
|
58 |
return array_values(array_filter($methods, function($name) { return ($name !== '__construct'); })); |
59 |
} |
60 |
|
61 |
public function addFilter(\closure $filter)100% |
62 |
{ |
63 |
$this->filters[] = $filter; |
64 |
|
65 |
return $this; |
66 |
} |
67 |
|
68 |
public function getFilters()100% |
69 |
{ |
70 |
return $this->filters; |
71 |
} |
72 |
|
73 |
public function resetFilters()100% |
74 |
{ |
75 |
$this->filters = array(); |
76 |
|
77 |
return $this; |
78 |
} |
79 |
} |