Completed
Branch tokens-class (82c54a)
by Tom
03:42
created
src/Property/Repeat.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,12 +18,16 @@  discard block
 block discarded – undo
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
@@ -46,13 +50,17 @@  discard block
 block discarded – undo
46 50
 	}
47 51
 
48 52
 	private function fixEmpty($value) {
49
- 		if (empty($value[0])) $value[0] = [];
53
+ 		if (empty($value[0])) {
54
+ 			$value[0] = [];
55
+ 		}
50 56
  		return $value;
51 57
  	}
52 58
 
53 59
 	private function tagElement($element, $count) {
54 60
 		//Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed
55
-		if ($count > 0) $element->setAttribute('transphporm', 'added');
61
+		if ($count > 0) {
62
+			$element->setAttribute('transphporm', 'added');
63
+		}
56 64
 	}
57 65
 
58 66
 	private function getMax($values) {
@@ -61,7 +69,9 @@  discard block
 block discarded – undo
61 69
 
62 70
 	private function createHook($newRules, $pseudoMatcher, $properties) {
63 71
 		$hook = new \Transphporm\Hook\PropertyHook($newRules, $this->baseDir, $this->baseDir, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet);
64
-		foreach ($properties as $name => $property) $hook->registerProperty($name, $property);
72
+		foreach ($properties as $name => $property) {
73
+			$hook->registerProperty($name, $property);
74
+		}
65 75
 		return $hook;
66 76
 	}
67 77
 }
Please login to merge, or discard this patch.