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