@@ -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 | |
@@ -52,7 +58,9 @@ discard block |
||
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 |
||
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 | } |
@@ -26,9 +26,13 @@ discard block |
||
26 | 26 | |
27 | 27 | public function run(\DomElement $element) { |
28 | 28 | $this->functionSet->setElement($element); |
29 | - if ($this->origBaseDir !== $this->newBaseDir) $this->origBaseDir = $this->newBaseDir; |
|
29 | + if ($this->origBaseDir !== $this->newBaseDir) { |
|
30 | + $this->origBaseDir = $this->newBaseDir; |
|
31 | + } |
|
30 | 32 | //Don't run if there's a pseudo element like nth-child() and this element doesn't match it |
31 | - if (!$this->pseudoMatcher->matches($element)) return; |
|
33 | + if (!$this->pseudoMatcher->matches($element)) { |
|
34 | + return; |
|
35 | + } |
|
32 | 36 | |
33 | 37 | // TODO: Have all rule values parsed before running them so that things like `content-append` are not expecting tokens |
34 | 38 | // problem with this is that anything in data changed by run properties is not shown |
@@ -36,7 +40,9 @@ discard block |
||
36 | 40 | |
37 | 41 | foreach ($this->rules as $name => $value) { |
38 | 42 | $result = $this->callProperty($name, $element, $this->getArgs($value, $element)); |
39 | - if ($result === false) break; |
|
43 | + if ($result === false) { |
|
44 | + break; |
|
45 | + } |
|
40 | 46 | } |
41 | 47 | } |
42 | 48 | |
@@ -49,6 +55,8 @@ discard block |
||
49 | 55 | } |
50 | 56 | |
51 | 57 | private function callProperty($name, $element, $value) { |
52 | - if (isset($this->properties[$name])) return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties); |
|
58 | + if (isset($this->properties[$name])) { |
|
59 | + return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties); |
|
60 | + } |
|
53 | 61 | } |
54 | 62 | } |