@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) { |
22 | 22 | $values = $this->fixEmpty($values); |
23 | - if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element); |
|
23 | + if ($element->getAttribute('transphporm') === 'added') { |
|
24 | + return $element->parentNode->removeChild($element); |
|
25 | + } |
|
24 | 26 | $max = $this->getMax($values); |
25 | 27 | $count = 0; |
26 | 28 | $repeat = $this->getRepeatValue($values, $max); |
@@ -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); |
@@ -55,7 +59,9 @@ discard block |
||
55 | 59 | } |
56 | 60 | |
57 | 61 | private function fixEmpty($value) { |
58 | - if (empty($value[0])) $value[0] = []; |
|
62 | + if (empty($value[0])) { |
|
63 | + $value[0] = []; |
|
64 | + } |
|
59 | 65 | return $value; |
60 | 66 | } |
61 | 67 | |
@@ -71,7 +77,9 @@ discard block |
||
71 | 77 | |
72 | 78 | private function tagElement($element, $count) { |
73 | 79 | //Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed |
74 | - if ($count > 0) $element->setAttribute('transphporm', 'added'); |
|
80 | + if ($count > 0) { |
|
81 | + $element->setAttribute('transphporm', 'added'); |
|
82 | + } |
|
75 | 83 | } |
76 | 84 | |
77 | 85 | private function getMax($values) { |
@@ -80,7 +88,9 @@ discard block |
||
80 | 88 | |
81 | 89 | private function createHook($newRules, $pseudoMatcher, $properties) { |
82 | 90 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $this->line, null, $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet, $this->filePath); |
83 | - foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
|
91 | + foreach ($properties as $name => $property) { |
|
92 | + $hook->registerProperty($name, $property); |
|
93 | + } |
|
84 | 94 | return $hook; |
85 | 95 | } |
86 | 96 | } |
@@ -14,15 +14,15 @@ |
||
14 | 14 | |
15 | 15 | public function getFilePath($filePath) { |
16 | 16 | if (is_file($filePath)) return $filePath; |
17 | - else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) return $this->baseDir . DIRECTORY_SEPARATOR . $filePath; |
|
17 | + else if (is_file($this->baseDir.DIRECTORY_SEPARATOR.$filePath)) return $this->baseDir.DIRECTORY_SEPARATOR.$filePath; |
|
18 | 18 | else return $this->loadFromPaths($filePath); |
19 | 19 | } |
20 | 20 | |
21 | 21 | private function loadFromPaths($filePath) { |
22 | 22 | foreach ($this->paths as $path) { |
23 | - if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) return $path . DIRECTORY_SEPARATOR . $filePath; |
|
23 | + if (is_file($path.DIRECTORY_SEPARATOR.$filePath)) return $path.DIRECTORY_SEPARATOR.$filePath; |
|
24 | 24 | } |
25 | 25 | |
26 | - throw new \Exception($filePath . ' not found in include path: ' . implode(';', $this->paths)); |
|
26 | + throw new \Exception($filePath.' not found in include path: '.implode(';', $this->paths)); |
|
27 | 27 | } |
28 | 28 | } |
@@ -13,14 +13,20 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | public function getFilePath($filePath) { |
16 | - if (is_file($filePath)) return $filePath; |
|
17 | - else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) return $this->baseDir . DIRECTORY_SEPARATOR . $filePath; |
|
18 | - else return $this->loadFromPaths($filePath); |
|
16 | + if (is_file($filePath)) { |
|
17 | + return $filePath; |
|
18 | + } else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) { |
|
19 | + return $this->baseDir . DIRECTORY_SEPARATOR . $filePath; |
|
20 | + } else { |
|
21 | + return $this->loadFromPaths($filePath); |
|
22 | + } |
|
19 | 23 | } |
20 | 24 | |
21 | 25 | private function loadFromPaths($filePath) { |
22 | 26 | foreach ($this->paths as $path) { |
23 | - if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) return $path . DIRECTORY_SEPARATOR . $filePath; |
|
27 | + if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) { |
|
28 | + return $path . DIRECTORY_SEPARATOR . $filePath; |
|
29 | + } |
|
24 | 30 | } |
25 | 31 | |
26 | 32 | throw new \Exception($filePath . ' not found in include path: ' . implode(';', $this->paths)); |