Completed
Push — master ( 5a4df6...185d8f )
by Tom
10:16
created
src/Template.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 	/** Loops through all assigned hooks, runs the Xpath query and calls the hook */
67 67
 	private function processHooks() {
68 68
 		foreach ($this->hooks as list($query, $hook)) {
69
-			foreach ($this->xpath->query($query) as $element) $hook->run($element);
69
+			foreach ($this->xpath->query($query) as $element) {
70
+				$hook->run($element);
71
+			}
70 72
 		}
71 73
 		$this->hooks = [];
72 74
 	}
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	/** Prints out the current DomDocument as HTML */
75 77
 	private function printDocument() {
76 78
 		$output = '';
77
-		foreach ($this->document->documentElement->childNodes as $node) $output .= call_user_func($this->save, $node);
79
+		foreach ($this->document->documentElement->childNodes as $node) {
80
+			$output .= call_user_func($this->save, $node);
81
+		}
78 82
 		return $output;
79 83
 	}
80 84
 
@@ -86,13 +90,18 @@  discard block
 block discarded – undo
86 90
 		//Generate the document by taking only the childnodes of the template, ignoring the <template> and </template> tags
87 91
 		//TODO: Is there a faster way of doing this without string manipulation on the output or this loop through childnodes?
88 92
 		 //Either return a whole DomDocument or return the output HTML
89
-		if ($document) return $this->document;
93
+		if ($document) {
94
+			return $this->document;
95
+		}
90 96
 
91 97
 		//Print the doctype... saveHtml inexplicably does not support $doc->doctype as an argument
92 98
 		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype) . "\n" : '';
93 99
 
94
-		if ($this->document->documentElement->tagName !== 'template') $output .= call_user_func($this->save, $this->document->documentElement);
95
-		else $output = $this->printDocument();
100
+		if ($this->document->documentElement->tagName !== 'template') {
101
+			$output .= call_user_func($this->save, $this->document->documentElement);
102
+		} else {
103
+			$output = $this->printDocument();
104
+		}
96 105
 
97 106
 		//repair empty tags. Browsers break on <script /> and <div /> so can't avoid LIBXML_NOEMPTYTAG but they also break on <base></base> so repair them
98 107
 		$output = str_replace(['></img>', '></br>', '></meta>', '></base>', '></link>', '></hr>', '></input>'], ' />', $output);
Please login to merge, or discard this patch.