Completed
Push — master ( 0ada29...ecc437 )
by Richard
03:53 queued 11s
created
src/Property/Content.php 1 patch
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,21 +15,28 @@  discard block
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
18
-		if (!$this->shouldRun($element)) return false;
18
+		if (!$this->shouldRun($element)) {
19
+			return false;
20
+		}
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
21 23
 		if (!$this->processPseudo($values, $element, $pseudoMatcher)) {
22 24
 			//Remove the current contents
23 25
 			$this->removeAllChildren($element);
24 26
 			//Now make a text node
25
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $values);
26
-			else $this->appendContent($element, $values);
27
+			if ($this->getContentMode($rules) === 'replace') {
28
+				$this->replaceContent($element, $values);
29
+			} else {
30
+				$this->appendContent($element, $values);
31
+			}
27 32
 		}
28 33
 	}
29 34
 
30 35
 	private function shouldRun($element) {
31 36
 		do {
32
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
37
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
38
+				return false;
39
+			}
33 40
 		}
34 41
 		while (($element = $element->parentNode) instanceof \DomElement);
35 42
 		return true;
@@ -53,9 +60,10 @@  discard block
 block discarded – undo
53 60
 	private function getNode($node, $document) {
54 61
 		foreach ($node as $n) {
55 62
 			if (is_array($n)) {
56
-				foreach ($this->getNode($n, $document) as $new) yield $new;
57
-			}
58
-			else {
63
+				foreach ($this->getNode($n, $document) as $new) {
64
+					yield $new;
65
+				}
66
+			} else {
59 67
 				yield $this->convertNode($n, $document);
60 68
 			}
61 69
 		}
@@ -66,9 +74,10 @@  discard block
 block discarded – undo
66 74
 			$new = $document->importNode($node, true);
67 75
 			//Removing this might cause problems with caching...
68 76
 			//$new->setAttribute('transphporm', 'added');
69
-		}
70
-		else {
71
-			if ($node instanceof \DomText) $node = $node->nodeValue;
77
+		} else {
78
+			if ($node instanceof \DomText) {
79
+				$node = $node->nodeValue;
80
+			}
72 81
 			$new = $document->createElement('text');
73 82
 
74 83
 			$new->appendChild($document->createTextNode($node));
@@ -114,6 +123,8 @@  discard block
 block discarded – undo
114 123
 	}
115 124
 
116 125
 	private function removeAllChildren($element) {
117
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
126
+		while ($element->hasChildNodes()) {
127
+			$element->removeChild($element->firstChild);
128
+		}
118 129
 	}
119 130
 }
Please login to merge, or discard this patch.
src/Config.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,12 +67,16 @@
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function loadProperties(Hook\PropertyHook $hook) {
70
-		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
70
+		foreach ($this->properties as $name => $property) {
71
+			$hook->registerProperty($name, $property);
72
+		}
71 73
 	}
72 74
 
73 75
 	public function createPseudoMatcher($pseudo) {
74 76
 		$pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser);
75
-		foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction(clone $pseudoFunction);
77
+		foreach ($this->pseudo as $pseudoFunction) {
78
+			$pseudoMatcher->registerFunction(clone $pseudoFunction);
79
+		}
76 80
 		return $pseudoMatcher;
77 81
 	}
78 82
 
Please login to merge, or discard this patch.
src/Pseudo/Nth.php 1 patch
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,19 @@
 block discarded – undo
11 11
 
12 12
 	public function match($name, $args, \DomElement $element) {
13 13
 		
14
-		if ($name !== 'nth-child') return true;
14
+		if ($name !== 'nth-child') {
15
+			return true;
16
+		}
15 17
 
16 18
 		$this->count++;
17 19
 		$criteria = $args[0];
18 20
 
19 21
 
20
-		if (is_callable([$this, $criteria])) return $this->$criteria($this->count);
21
-		else return $this->count == $criteria;
22
+		if (is_callable([$this, $criteria])) {
23
+			return $this->$criteria($this->count);
24
+		} else {
25
+			return $this->count == $criteria;
26
+		}
22 27
 	}
23 28
 
24 29
 	private function odd($num) {
Please login to merge, or discard this patch.
src/Property/Repeat.php 1 patch
Braces   +18 added lines, -6 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
@@ -36,7 +40,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.