Completed
Pull Request — master (#239)
by Nathan
13s
created
src/Builder.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 		$this->cache = new Cache(new \ArrayObject());
29 29
 		$this->filePath = new FilePath();
30 30
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
31
-		foreach ($modules as $module) $this->loadModule(new $module);
31
+		foreach ($modules as $module) {
32
+			$this->loadModule(new $module);
33
+		}
32 34
 	}
33 35
 
34 36
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -87,7 +89,9 @@  discard block
 block discarded – undo
87 89
 		$valueParser = new Parser\Value($functionSet);
88 90
 		$this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5((string)$this->tss)), $this->filePath, $headers);
89 91
 
90
-		foreach ($this->modules as $module) $module->load($this->config);
92
+		foreach ($this->modules as $module) {
93
+			$module->load($this->config);
94
+		}
91 95
 		return $template;
92 96
 	}
93 97
 
@@ -101,7 +105,9 @@  discard block
 block discarded – undo
101 105
 	//Load a template, firstly check if it's a file or a valid string
102 106
 	private function loadTemplate() {
103 107
         $result = ['cache' => $this->template, 'headers' => []];
104
-		if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template);
108
+		if (strpos($this->template, "\n") === false && is_file($this->template)) {
109
+			$result = $this->loadTemplateFromFile($this->template);
110
+		}
105 111
 		return $result;
106 112
 	}
107 113
 
@@ -120,6 +126,8 @@  discard block
 block discarded – undo
120 126
 
121 127
 	public function __destruct() {
122 128
 		//Required hack as DomXPath can only register static functions clear the statically stored instance to avoid memory leaks
123
-		if (isset($this->config)) $this->config->getCssToXpath()->cleanup();
129
+		if (isset($this->config)) {
130
+			$this->config->getCssToXpath()->cleanup();
131
+		}
124 132
 	}
125 133
 }
Please login to merge, or discard this patch.
src/Parser/TokenFilterIterator.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 
36 36
     public function rewind(): void {
37 37
         $this->tokens->rewind();
38
-        while ($this->shouldContinue()) $this->tokens->next();
38
+        while ($this->shouldContinue()) {
39
+        	$this->tokens->next();
40
+        }
39 41
     }
40 42
 
41 43
     private function shouldContinue() {
Please login to merge, or discard this patch.
src/Module/Format.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,9 +14,13 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	private function getLocale() {
17
-		if (is_array($this->locale)) return $this->locale;
18
-		else if (strlen((string)$this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
19
-		else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
17
+		if (is_array($this->locale)) {
18
+			return $this->locale;
19
+		} else if (strlen((string)$this->locale) > 0) {
20
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
21
+		} else {
22
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
23
+		}
20 24
 	}
21 25
 
22 26
 	public function load(\Transphporm\Config $config) {
Please login to merge, or discard this patch.
src/Property/Content.php 1 patch
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
17
-		if (!$this->shouldRun($element)) return false;
17
+		if (!$this->shouldRun($element)) {
18
+			return false;
19
+		}
18 20
 
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
@@ -25,14 +27,17 @@  discard block
 block discarded – undo
25 27
 			if ($this->getContentMode($rules) === 'replace') {
26 28
 				$contentReplace = new ContentReplace($this);
27 29
 				$contentReplace->replaceContent($element, $values);
30
+			} else {
31
+				$this->appendContent($element, $values);
28 32
 			}
29
-			else $this->appendContent($element, $values);
30 33
 		}
31 34
 	}
32 35
 
33 36
 	private function shouldRun($element) {
34 37
 		do {
35
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
38
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
39
+				return false;
40
+			}
36 41
 		}
37 42
 		while (($element = $element->parentNode) instanceof \DomElement);
38 43
 		return true;
@@ -59,9 +64,10 @@  discard block
 block discarded – undo
59 64
 	public function getNode($node, $document) {
60 65
 		foreach ($node as $n) {
61 66
 			if (is_array($n)) {
62
-				foreach ($this->getNode($n, $document) as $new) yield $new;
63
-			}
64
-			else {
67
+				foreach ($this->getNode($n, $document) as $new) {
68
+					yield $new;
69
+				}
70
+			} else {
65 71
 				yield $this->convertNode($n, $document);
66 72
 			}
67 73
 		}
@@ -70,9 +76,10 @@  discard block
 block discarded – undo
70 76
 	private function convertNode($node, $document) {
71 77
 		if ($node instanceof \DomElement || $node instanceof \DOMComment) {
72 78
 			$new = $document->importNode($node, true);
73
-		}
74
-		else {
75
-			if ($node instanceof \DomText) $node = $node->nodeValue;
79
+		} else {
80
+			if ($node instanceof \DomText) {
81
+				$node = $node->nodeValue;
82
+			}
76 83
 			$new = $document->createElement('text');
77 84
 
78 85
 			$new->appendChild($document->createTextNode($node !== null ? $node : ''));
@@ -89,6 +96,8 @@  discard block
 block discarded – undo
89 96
 	}
90 97
 
91 98
 	private function removeAllChildren($element) {
92
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
99
+		while ($element->hasChildNodes()) {
100
+			$element->removeChild($element->firstChild);
101
+		}
93 102
 	}
94 103
 }
Please login to merge, or discard this patch.
src/Formatter/Date.php 1 patch
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,11 @@  discard block
 block discarded – undo
51 51
 		$diff = $now->diff($date);
52 52
 		$diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days;
53 53
 
54
-		if ($diffDays !== 0) return $this->dayOffset($diffDays);
55
-		else return $this->timeOffset($diff);
54
+		if ($diffDays !== 0) {
55
+			return $this->dayOffset($diffDays);
56
+		} else {
57
+			return $this->timeOffset($diff);
58
+		}
56 59
 	}
57 60
 
58 61
 	/** Calculates offset in hours/minutes/seconds */
@@ -89,8 +92,12 @@  discard block
 block discarded – undo
89 92
 			[-365, -28, $strings['future'], 28, 'months'],
90 93
 			[-999999, -365, $strings['future'], 365, 'years'],
91 94
 		];
92
-		if (isset($strings['day_before_yesterday'])) $this->add2DayRanges($ranges, $strings['day_before_yesterday'], "before");
93
-		if (isset($strings['day_after_tomorrow'])) $this->add2DayRanges($ranges, $strings['day_after_tomorrow'], "after");
95
+		if (isset($strings['day_before_yesterday'])) {
96
+			$this->add2DayRanges($ranges, $strings['day_before_yesterday'], "before");
97
+		}
98
+		if (isset($strings['day_after_tomorrow'])) {
99
+			$this->add2DayRanges($ranges, $strings['day_after_tomorrow'], "after");
100
+		}
94 101
 		return $ranges;
95 102
 	}
96 103
 
@@ -101,8 +108,11 @@  discard block
 block discarded – undo
101 108
 
102 109
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
103 110
 	private function getPlural($strings, $num, $interval) {
104
-		if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
105
-		else return '';
111
+		if ($interval !== '') {
112
+			return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
113
+		} else {
114
+			return '';
115
+		}
106 116
 	}
107 117
 
108 118
 	/** Calculates offset in days/weeks/month/years */
Please login to merge, or discard this patch.