@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) { |
20 | 20 | $values = $this->fixEmpty($values); |
21 | - if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element); |
|
21 | + if ($element->getAttribute('transphporm') === 'added') { |
|
22 | + return $element->parentNode->removeChild($element); |
|
23 | + } |
|
22 | 24 | $max = $this->getMax($values); |
23 | 25 | $count = 0; |
24 | 26 | |
@@ -29,7 +31,9 @@ discard block |
||
29 | 31 | $hook = $this->createHook($rules, $pseudoMatcher, $properties); |
30 | 32 | |
31 | 33 | foreach ($repeat as $key => $iteration) { |
32 | - if ($count+1 > $max) break; |
|
34 | + if ($count+1 > $max) { |
|
35 | + break; |
|
36 | + } |
|
33 | 37 | $clone = $this->cloneElement($element, $iteration, $key, $count++); |
34 | 38 | //Re-run the hook on the new element, but use the iterated data |
35 | 39 | $hook->run($clone); |
@@ -41,8 +45,9 @@ discard block |
||
41 | 45 | |
42 | 46 | private function getRepeatValue($values, &$max) { |
43 | 47 | $mode = $this->getMode($values); |
44 | - if ($mode === 'each') $repeat = $values[0]; |
|
45 | - else if ($mode === 'loop') { |
|
48 | + if ($mode === 'each') { |
|
49 | + $repeat = $values[0]; |
|
50 | + } else if ($mode === 'loop') { |
|
46 | 51 | $repeat = range($values[0], $max); |
47 | 52 | $max++; |
48 | 53 | } |
@@ -54,7 +59,9 @@ discard block |
||
54 | 59 | } |
55 | 60 | |
56 | 61 | private function fixEmpty($value) { |
57 | - if (empty($value[0])) $value[0] = []; |
|
62 | + if (empty($value[0])) { |
|
63 | + $value[0] = []; |
|
64 | + } |
|
58 | 65 | return $value; |
59 | 66 | } |
60 | 67 | |
@@ -70,7 +77,9 @@ discard block |
||
70 | 77 | |
71 | 78 | private function tagElement($element, $count) { |
72 | 79 | //Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed |
73 | - if ($count > 0) $element->setAttribute('transphporm', 'added'); |
|
80 | + if ($count > 0) { |
|
81 | + $element->setAttribute('transphporm', 'added'); |
|
82 | + } |
|
74 | 83 | } |
75 | 84 | |
76 | 85 | private function getMax($values) { |
@@ -81,7 +90,9 @@ discard block |
||
81 | 90 | $var = ""; // PropertyHook requires that baseDir be passed by refrence |
82 | 91 | // and there is no reason to pass it so create $var to avoid errors |
83 | 92 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $var, $this->line, "", $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet); |
84 | - foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
|
93 | + foreach ($properties as $name => $property) { |
|
94 | + $hook->registerProperty($name, $property); |
|
95 | + } |
|
85 | 96 | return $hook; |
86 | 97 | } |
87 | 98 | } |