Completed
Push — master ( b867be...9aca1e )
by Richard
02:41
created
src/Property/Content.php 1 patch
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  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
 
20 22
 		$values = $this->formatter->format($values, $rules);
21 23
 
@@ -23,14 +25,19 @@  discard block
 block discarded – undo
23 25
 			//Remove the current contents
24 26
 			$this->removeAllChildren($element);
25 27
 			//Now make a text node
26
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $values);
27
-			else $this->appendContent($element, $values);
28
+			if ($this->getContentMode($rules) === 'replace') {
29
+				$this->replaceContent($element, $values);
30
+			} else {
31
+				$this->appendContent($element, $values);
32
+			}
28 33
 		}
29 34
 	}
30 35
 
31 36
 	private function shouldRun($element) {
32 37
 		do {
33
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
38
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
39
+				return false;
40
+			}
34 41
 		}
35 42
 		while (($element = $element->parentNode) instanceof \DomElement);
36 43
 		return true;
@@ -54,10 +61,12 @@  discard block
 block discarded – undo
54 61
 	private function getNode($node, $document) {
55 62
 		foreach ($node as $n) {
56 63
 			if (is_array($n)) {
57
-				foreach ($this->getNode($n, $document) as $new) yield $new;
58
-			}
59
-			else if ($n instanceof \DOMComment) continue;
60
-			else {
64
+				foreach ($this->getNode($n, $document) as $new) {
65
+					yield $new;
66
+				}
67
+			} else if ($n instanceof \DOMComment) {
68
+				continue;
69
+			} else {
61 70
 				yield $this->convertNode($n, $document);
62 71
 			}
63 72
 		}
@@ -68,9 +77,10 @@  discard block
 block discarded – undo
68 77
 			$new = $document->importNode($node, true);
69 78
 			//Removing this might cause problems with caching...
70 79
 			//$new->setAttribute('transphporm', 'added');
71
-		}
72
-		else {
73
-			if ($node instanceof \DomText) $node = $node->nodeValue;
80
+		} else {
81
+			if ($node instanceof \DomText) {
82
+				$node = $node->nodeValue;
83
+			}
74 84
 			$new = $document->createElement('text');
75 85
 
76 86
 			$new->appendChild($document->createTextNode($node));
@@ -117,6 +127,8 @@  discard block
 block discarded – undo
117 127
 	}
118 128
 
119 129
 	private function removeAllChildren($element) {
120
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
130
+		while ($element->hasChildNodes()) {
131
+			$element->removeChild($element->firstChild);
132
+		}
121 133
 	}
122 134
 }
Please login to merge, or discard this patch.