82% of 211OPs |
100% of 34Lines |
71% of 38Branches |
48% of 21Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\template\iterator::addTag() | 48 | 100% | 9 | 100% | 8 | 100% | 3 | 100% |
mageekguy\atoum\template\iterator::__get() | 28 | 64% | 5 | 100% | 6 | 67% | 3 | 33% |
mageekguy\atoum\template\iterator::__set() | 18 | 67% | 4 | 100% | 6 | 50% | 3 | 0% |
mageekguy\atoum\template\iterator::__unset() | 20 | 55% | 4 | 100% | 6 | 50% | 3 | 0% |
mageekguy\atoum\template\iterator::__call() | 24 | 50% | 4 | 100% | 6 | 50% | 3 | 0% |
mageekguy\atoum\template\iterator::rewind() | 12 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\template\iterator::valid() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\template\iterator::current() | 14 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\template\iterator::key() | 11 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\template\iterator::next() | 12 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\template\iterator::count() | 11 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\template; |
4 |
|
5 |
use |
6 |
mageekguy\atoum |
7 |
; |
8 |
|
9 |
class iterator implements \iterator, \countable |
10 |
{ |
11 |
protected $tags = array(); |
12 |
|
13 |
public function addTag($tag, atoum\template $template)100% |
14 |
{ |
15 |
$children = $template->getChildren(); |
16 |
|
17 |
while (($child = array_shift($children)) !== null) |
18 |
{ |
19 |
if ($child->getTag() === $tag) |
20 |
{ |
21 |
$this->tags[] = $child; |
22 |
} |
23 |
|
24 |
$children = array_merge($child->getChildren(), $children); |
25 |
} |
26 |
|
27 |
return $this; |
28 |
} |
29 |
|
30 |
public function __get($tag)100% |
31 |
{ |
32 |
$iterator = new self(); |
33 |
|
34 |
foreach ($this->tags as $innerTag) |
35 |
{ |
36 |
$iterator->addTag($tag, $innerTag); |
37 |
} |
38 |
|
39 |
return $iterator; |
40 |
} |
41 |
|
42 |
public function __set($tag, $data)100% |
43 |
{ |
44 |
foreach ($this->tags as $innerTag) |
45 |
{ |
46 |
$innerTag->{$tag} = $data; |
47 |
} |
48 |
|
49 |
return $this; |
50 |
} |
51 |
|
52 |
public function __unset($tag)100% |
53 |
{ |
54 |
foreach ($this->tags as $innerTag) |
55 |
{ |
56 |
$innerTag->{$tag}->resetData(); |
57 |
} |
58 |
|
59 |
return $this; |
60 |
} |
61 |
|
62 |
public function __call($method, $arguments)100% |
63 |
{ |
64 |
foreach ($this->tags as $innerTag) |
65 |
{ |
66 |
call_user_func_array(array($innerTag, $method), $arguments); |
67 |
} |
68 |
|
69 |
return $this; |
70 |
} |
71 |
|
72 |
public function rewind()100% |
73 |
{ |
74 |
reset($this->tags); |
75 |
|
76 |
return $this; |
77 |
} |
78 |
|
79 |
public function valid()100% |
80 |
{ |
81 |
return (key($this->tags) !== null); |
82 |
} |
83 |
|
84 |
public function current()100% |
85 |
{ |
86 |
return current($this->tags) ?: null; |
87 |
} |
88 |
|
89 |
public function key()100% |
90 |
{ |
91 |
return key($this->tags); |
92 |
} |
93 |
|
94 |
public function next()100% |
95 |
{ |
96 |
next($this->tags); |
97 |
|
98 |
return $this; |
99 |
} |
100 |
|
101 |
public function count()100% |
102 |
{ |
103 |
return sizeof($this->tags); |
104 |
} |
105 |
} |