Completed
Push — master ( 38f5f5...09a120 )
by Tom
02:16
created
src/Property/Content.php 1 patch
Braces   +24 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,22 +18,31 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function run($value, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
21
-		if ($this->isIncludedTemplate($element)) return false;
22
-		if ($element->getAttribute('transphporm') === 'remove') return false;
21
+		if ($this->isIncludedTemplate($element)) {
22
+			return false;
23
+		}
24
+		if ($element->getAttribute('transphporm') === 'remove') {
25
+			return false;
26
+		}
23 27
 	
24 28
 		$value = $this->formatter->format($value, $rules);
25 29
 		if (!$this->processPseudo($value, $element, $pseudoMatcher)) {
26 30
 			//Remove the current contents
27 31
 			$this->removeAllChildren($element);
28 32
 			//Now make a text node
29
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $value);
30
-			else $this->appendContent($element, $value);
33
+			if ($this->getContentMode($rules) === 'replace') {
34
+				$this->replaceContent($element, $value);
35
+			} else {
36
+				$this->appendContent($element, $value);
37
+			}
31 38
 		}
32 39
 	}
33 40
 
34 41
 	private function isIncludedTemplate($element) {
35 42
 		do {
36
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return true;
43
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
44
+				return true;
45
+			}
37 46
 		}
38 47
 		while (($element = $element->parentNode) instanceof \DomElement);
39 48
 		return false;
@@ -60,9 +69,10 @@  discard block
 block discarded – undo
60 69
 				$new = $document->importNode($n, true);
61 70
 				//Removing this might cause problems with caching... 
62 71
 				//$new->setAttribute('transphporm', 'added');
63
-			}
64
-			else {
65
-				if ($n instanceof \DomText) $n = $n->nodeValue;
72
+			} else {
73
+				if ($n instanceof \DomText) {
74
+					$n = $n->nodeValue;
75
+				}
66 76
 				$new = $document->createElement('text');
67 77
 				$new->appendChild($document->createTextNode($n));
68 78
 				$new->setAttribute('transphporm', 'text');
@@ -98,7 +108,9 @@  discard block
 block discarded – undo
98 108
 		while ($e = $e->previousSibling && !in_array($e->getAttribute('transphporm'), [null, 'remove'])) {
99 109
 			$remove[] = $e;
100 110
 		}
101
-		foreach ($remove as $r) $r->parentNode->removeChild($r);
111
+		foreach ($remove as $r) {
112
+			$r->parentNode->removeChild($r);
113
+		}
102 114
 	}
103 115
 
104 116
 	private function replaceContent($element, $content) {
@@ -117,6 +129,8 @@  discard block
 block discarded – undo
117 129
 	}
118 130
 	
119 131
 	private function removeAllChildren($element) {
120
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
132
+		while ($element->hasChildNodes()) {
133
+			$element->removeChild($element->firstChild);
134
+		}
121 135
 	}
122 136
 }
123 137
\ No newline at end of file
Please login to merge, or discard this patch.