Completed
Push — master ( df9391...319ec0 )
by Tom
01:40
created
src/FilePath.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@
 block discarded – undo
19 19
 
20 20
 	public function getFilePath($filePath) {
21 21
 		if (is_file($filePath)) return $filePath;
22
-		else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) return $this->baseDir . DIRECTORY_SEPARATOR . $filePath;
22
+		else if (is_file($this->baseDir.DIRECTORY_SEPARATOR.$filePath)) return $this->baseDir.DIRECTORY_SEPARATOR.$filePath;
23 23
 		else return $this->loadFromPaths($filePath);
24 24
 	}
25 25
 
26 26
 	private function loadFromPaths($filePath) {
27 27
 		foreach ($this->paths as $path) {
28
-			if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) return $path . DIRECTORY_SEPARATOR . $filePath;
28
+			if (is_file($path.DIRECTORY_SEPARATOR.$filePath)) return $path.DIRECTORY_SEPARATOR.$filePath;
29 29
 		}
30 30
 
31
-		throw new \Exception('File ' . $filePath . ' not found in paths (' . implode(', ', $this->paths) . ')');
31
+		throw new \Exception('File '.$filePath.' not found in paths ('.implode(', ', $this->paths).')');
32 32
 	}
33 33
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,14 +18,20 @@
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function getFilePath($filePath) {
21
-		if (is_file($filePath)) return $filePath;
22
-		else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) return $this->baseDir . DIRECTORY_SEPARATOR . $filePath;
23
-		else return $this->loadFromPaths($filePath);
21
+		if (is_file($filePath)) {
22
+			return $filePath;
23
+		} else if (is_file($this->baseDir . DIRECTORY_SEPARATOR . $filePath)) {
24
+			return $this->baseDir . DIRECTORY_SEPARATOR . $filePath;
25
+		} else {
26
+			return $this->loadFromPaths($filePath);
27
+		}
24 28
 	}
25 29
 
26 30
 	private function loadFromPaths($filePath) {
27 31
 		foreach ($this->paths as $path) {
28
-			if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) return $path . DIRECTORY_SEPARATOR . $filePath;
32
+			if (is_file($path . DIRECTORY_SEPARATOR . $filePath)) {
33
+				return $path . DIRECTORY_SEPARATOR . $filePath;
34
+			}
29 35
 		}
30 36
 
31 37
 		throw new \Exception('File ' . $filePath . ' not found in paths (' . implode(', ', $this->paths) . ')');
Please login to merge, or discard this patch.
src/Template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$this->save = function($content = null) {
39 39
 				return $this->document->saveHtml($content);
40 40
 			};
41
-			$this->document->loadHtml('<' . '?xml encoding="UTF-8">' . $doc,  LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
41
+			$this->document->loadHtml('<'.'?xml encoding="UTF-8">'.$doc, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
42 42
 
43 43
 		}
44 44
 		else {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		if ($document) return $this->document;
90 90
 
91 91
 		//Print the doctype... saveHtml inexplicably does not support $doc->doctype as an argument
92
-		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype) . "\n" : '';
92
+		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype)."\n" : '';
93 93
 
94 94
 		if ($this->document->documentElement->tagName !== 'template') $output .= call_user_func($this->save, $this->document->documentElement);
95 95
 		else $output = $this->printDocument();
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 			};
41 41
 			$this->document->loadHtml('<' . '?xml encoding="UTF-8">' . $doc,  LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
42 42
 
43
-		}
44
-		else {
43
+		} else {
45 44
 			$this->document->loadXml($doc);
46 45
 			//XML was loaded, save as XML.
47 46
 			$this->save = function($content = null) {
@@ -66,7 +65,9 @@  discard block
 block discarded – undo
66 65
 	/** Loops through all assigned hooks, runs the Xpath query and calls the hook */
67 66
 	private function processHooks() {
68 67
 		foreach ($this->hooks as list($query, $hook)) {
69
-			foreach ($this->xpath->query($query) as $element) $hook->run($element);
68
+			foreach ($this->xpath->query($query) as $element) {
69
+				$hook->run($element);
70
+			}
70 71
 		}
71 72
 		$this->hooks = [];
72 73
 	}
@@ -74,7 +75,9 @@  discard block
 block discarded – undo
74 75
 	/** Prints out the current DomDocument as HTML */
75 76
 	private function printDocument() {
76 77
 		$output = '';
77
-		foreach ($this->document->documentElement->childNodes as $node) $output .= call_user_func($this->save, $node);
78
+		foreach ($this->document->documentElement->childNodes as $node) {
79
+			$output .= call_user_func($this->save, $node);
80
+		}
78 81
 		return $output;
79 82
 	}
80 83
 
@@ -86,13 +89,18 @@  discard block
 block discarded – undo
86 89
 		//Generate the document by taking only the childnodes of the template, ignoring the <template> and </template> tags
87 90
 		//TODO: Is there a faster way of doing this without string manipulation on the output or this loop through childnodes?
88 91
 		 //Either return a whole DomDocument or return the output HTML
89
-		if ($document) return $this->document;
92
+		if ($document) {
93
+			return $this->document;
94
+		}
90 95
 
91 96
 		//Print the doctype... saveHtml inexplicably does not support $doc->doctype as an argument
92 97
 		$output = ($this->document->doctype) ? $this->document->saveXml($this->document->doctype) . "\n" : '';
93 98
 
94
-		if ($this->document->documentElement->tagName !== 'template') $output .= call_user_func($this->save, $this->document->documentElement);
95
-		else $output = $this->printDocument();
99
+		if ($this->document->documentElement->tagName !== 'template') {
100
+			$output .= call_user_func($this->save, $this->document->documentElement);
101
+		} else {
102
+			$output = $this->printDocument();
103
+		}
96 104
 
97 105
 		//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 106
 		$output = str_replace(['></img>', '></br>', '></meta>', '></base>', '></link>', '></hr>', '></input>'], ' />', $output);
Please login to merge, or discard this patch.
src/TSSFunction/Json.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
 
18 18
 		if ($this->isJsonFile($json)) {
19 19
 			$path = $this->filePath->getFilePath($json);
20
-			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
20
+			if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path);
21 21
 			$json = file_get_contents($path);
22 22
 		}
23 23
 
24 24
 		$map = json_decode($json, true);
25 25
 
26
-		if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
26
+		if (!is_array($map)) throw new \Exception('Could not decode json: '.json_last_error_msg());
27 27
 
28 28
 		return $map;
29 29
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,13 +17,17 @@
 block discarded – undo
17 17
 
18 18
 		if ($this->isJsonFile($json)) {
19 19
 			$path = $this->filePath->getFilePath($json);
20
-			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
20
+			if (!file_exists($path)) {
21
+				throw new \Exception('File does not exist at: ' . $path);
22
+			}
21 23
 			$json = file_get_contents($path);
22 24
 		}
23 25
 
24 26
 		$map = json_decode($json, true);
25 27
 
26
-		if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
28
+		if (!is_array($map)) {
29
+			throw new \Exception('Could not decode json: ' . json_last_error_msg());
30
+		}
27 31
 
28 32
 		return $map;
29 33
 	}
Please login to merge, or discard this patch.
src/Hook/ElementData.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@
 block discarded – undo
25 25
 	/** Returns the data that has been bound to $element, or, if no data is bound to $element climb the DOM tree to find the data bound to a parent node*/
26 26
 	public function getData(\DomElement $element = null, $type = 'data') {
27 27
 		while ($element) {
28
-			if (isset($this->elementMap[$element]) && array_key_exists($type, $this->elementMap[$element])) return $this->elementMap[$element][$type];
28
+			if (isset($this->elementMap[$element]) && array_key_exists($type, $this->elementMap[$element])) {
29
+				return $this->elementMap[$element][$type];
30
+			}
29 31
 			$element = $element->parentNode;
30 32
 		}
31 33
 		return $this->data;
Please login to merge, or discard this patch.