Completed
Push — master ( 9aca1e...d42201 )
by Richard
03:32
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.