@@ -18,12 +18,16 @@ 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 | |
| 25 | 27 | foreach ($values[0] as $key => $iteration) { |
| 26 | - if ($count+1 > $max) break; |
|
| 28 | + if ($count+1 > $max) { |
|
| 29 | + break; |
|
| 30 | + } |
|
| 27 | 31 | $clone = $this->cloneElement($element, $iteration, $key, $count++); |
| 28 | 32 | //Re-run the hook on the new element, but use the iterated data |
| 29 | 33 | //Don't run repeat on the clones element or it will loop forever |
@@ -36,7 +40,9 @@ discard block |
||
| 36 | 40 | } |
| 37 | 41 | |
| 38 | 42 | private function fixEmpty($value) { |
| 39 | - if (empty($value[0])) $value[0] = []; |
|
| 43 | + if (empty($value[0])) { |
|
| 44 | + $value[0] = []; |
|
| 45 | + } |
|
| 40 | 46 | return $value; |
| 41 | 47 | } |
| 42 | 48 | |
@@ -51,13 +57,17 @@ discard block |
||
| 51 | 57 | } |
| 52 | 58 | |
| 53 | 59 | private function fixEmpty($value) { |
| 54 | - if (empty($value[0])) $value[0] = []; |
|
| 60 | + if (empty($value[0])) { |
|
| 61 | + $value[0] = []; |
|
| 62 | + } |
|
| 55 | 63 | return $value; |
| 56 | 64 | } |
| 57 | 65 | |
| 58 | 66 | private function tagElement($element, $count) { |
| 59 | 67 | //Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed |
| 60 | - if ($count > 0) $element->setAttribute('transphporm', 'added'); |
|
| 68 | + if ($count > 0) { |
|
| 69 | + $element->setAttribute('transphporm', 'added'); |
|
| 70 | + } |
|
| 61 | 71 | } |
| 62 | 72 | |
| 63 | 73 | private function getMax($values) { |
@@ -66,7 +76,9 @@ discard block |
||
| 66 | 76 | |
| 67 | 77 | private function createHook($newRules, $pseudoMatcher, $properties) { |
| 68 | 78 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $this->baseDir, $this->baseDir, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet); |
| 69 | - foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
|
| 79 | + foreach ($properties as $name => $property) { |
|
| 80 | + $hook->registerProperty($name, $property); |
|
| 81 | + } |
|
| 70 | 82 | return $hook; |
| 71 | 83 | } |
| 72 | 84 | } |