Completed
Push — master ( 5ec81c...d5ea32 )
by Richard
03:52
created
src/Pseudo/Nth.php 1 patch
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,20 +11,28 @@
 block discarded – undo
11 11
 	private $lastParentNode;
12 12
 
13 13
 	public function match($name, $args, \DomElement $element) {
14
-		if ($element->parentNode !== $this->lastParentNode) $this->count = 0;
14
+		if ($element->parentNode !== $this->lastParentNode) {
15
+			$this->count = 0;
16
+		}
15 17
 
16 18
 		$this->lastParentNode = $element->parentNode;
17 19
 
18 20
 
19 21
 
20
-		if ($name !== 'nth-child') return true;
22
+		if ($name !== 'nth-child') {
23
+			return true;
24
+		}
21 25
 
22 26
 		$this->count++;
23 27
 		$criteria = $args[0];
24 28
 
25
-		if (is_callable([$this, $criteria])) return $this->$criteria($this->count);
26
-		else if (!is_numeric($criteria)) throw new \Exception("Argument passed to 'nth-child' must be 'odd', 'even', or of type int");
27
-		else return $this->count == $criteria;
29
+		if (is_callable([$this, $criteria])) {
30
+			return $this->$criteria($this->count);
31
+		} else if (!is_numeric($criteria)) {
32
+			throw new \Exception("Argument passed to 'nth-child' must be 'odd', 'even', or of type int");
33
+		} else {
34
+			return $this->count == $criteria;
35
+		}
28 36
 	}
29 37
 
30 38
 	private function odd($num) {
Please login to merge, or discard this patch.
src/Parser/Value.php 1 patch
Braces   +22 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 		$this->data = new ValueData($data ? $data : $this->baseData);
50 50
 		$this->last = null;
51 51
 
52
-		if (count($tokens) <= 0) return [$data];
52
+		if (count($tokens) <= 0) {
53
+			return [$data];
54
+		}
53 55
 
54 56
 		foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $token) {
55 57
 			$this->{$this->tokenFuncs[$token['type']]}($token);
@@ -71,13 +73,15 @@  discard block
 block discarded – undo
71 73
 	//Reads the last selected value from $data regardless if it's an array or object and overrides $this->data with the new value
72 74
 	//Dot moves $data to the next object in $data foo.bar moves the $data pointer from `foo` to `bar`
73 75
 	private function processDot($token) {
74
-		if ($this->last !== null) $this->data->traverse($this->last);
75
-		else {
76
+		if ($this->last !== null) {
77
+			$this->data->traverse($this->last);
78
+		} else {
76 79
 			//When . is not preceeded by anything, treat it as part of the string instead of an operator
77 80
 			// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
78 81
 			$lastResult = $this->result->pop();
79
-			if ($lastResult) $this->data = new ValueData($lastResult);
80
-			else {
82
+			if ($lastResult) {
83
+				$this->data = new ValueData($lastResult);
84
+			} else {
81 85
 				$this->processString(['value' => '.']);
82 86
 				$this->result->setMode(Tokenizer::CONCAT);
83 87
 			}
@@ -90,12 +94,14 @@  discard block
 block discarded – undo
90 94
 		$parser = new Value($this->baseData, $this->autoLookup);
91 95
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
92 96
 			$this->callTransphpormFunctions($token);
93
-		}
94
-		else {
95
-			if ($this->last !== null) $this->data->traverse($this->last);
96
-			else {
97
+		} else {
98
+			if ($this->last !== null) {
99
+				$this->data->traverse($this->last);
100
+			} else {
97 101
 				$lastResult = $this->result->pop();
98
-				if ($lastResult) $this->data = new ValueData($lastResult);
102
+				if ($lastResult) {
103
+					$this->data = new ValueData($lastResult);
104
+				}
99 105
 			}
100 106
 			$this->last = $parser->parseTokens($token['value'], null)[0];
101 107
 		}
@@ -116,8 +122,7 @@  discard block
 block discarded – undo
116 122
 	private function processBrackets($token) {
117 123
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
118 124
 			$this->callTransphpormFunctions($token);
119
-		}
120
-		else {
125
+		} else {
121 126
 			$this->processNested($token);
122 127
 		}
123 128
 	}
@@ -134,7 +139,9 @@  discard block
 block discarded – undo
134 139
 		foreach ($this->result->getResult() as $i => $value) {
135 140
 			if (is_scalar($value)) {
136 141
 				$val = $this->data->read($value);
137
-				if ($val) $this->result[$i] = $val;
142
+				if ($val) {
143
+					$this->result[$i] = $val;
144
+				}
138 145
 			}
139 146
 		}
140 147
 		$this->last = null;
@@ -146,12 +153,10 @@  discard block
 block discarded – undo
146 153
 			try {
147 154
 				$value = $this->data->extract($this->last, $this->autoLookup);
148 155
 				$this->result->processValue($value);
149
-			}
150
-			catch (\UnexpectedValueException $e) {
156
+			} catch (\UnexpectedValueException $e) {
151 157
 				if (!$this->autoLookup) {
152 158
 					$this->result->processValue($this->last);
153
-				}
154
-				else {
159
+				} else {
155 160
 					$this->result->clear();
156 161
 					$this->result[0] = false;
157 162
 				}
Please login to merge, or discard this patch.
src/TSSCache.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class TSSCache {
4
-    private $cache;
5
-    private $prefix;
4
+	private $cache;
5
+	private $prefix;
6 6
 
7
-    public function __construct(Cache $cache, $prefix) {
8
-        $this->cache = $cache;
9
-        $this->prefix = $prefix;
10
-    }
7
+	public function __construct(Cache $cache, $prefix) {
8
+		$this->cache = $cache;
9
+		$this->prefix = $prefix;
10
+	}
11 11
 
12 12
 	private function getRulesFromCache($file) {
13 13
 		//The cache for the key: the filename and template prefix
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31
-    public function load($tss) {
32
-        return $this->getRulesFromCache($tss);
33
-    }
31
+	public function load($tss) {
32
+		return $this->getRulesFromCache($tss);
33
+	}
34 34
 
35
-    public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
-        return $rules;
38
-    }
35
+	public function write($file, $rules, $imports = []) {
36
+		if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
+		return $rules;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	private function getCacheKey($file) {
28
-		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
28
+		return $file.$this->prefix.dirname(realpath($file)).DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31 31
     public function load($tss) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 		$rules = $this->cache->load($key, filemtime($file));
19 19
 		if ($rules) {
20 20
 			foreach ($rules['import'] as $file) {
21
-				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) return false;
21
+				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) {
22
+					return false;
23
+				}
22 24
 			}
23 25
 		}
24 26
 		return $rules;
@@ -33,7 +35,9 @@  discard block
 block discarded – undo
33 35
     }
34 36
 
35 37
     public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
38
+        if (is_file($file)) {
39
+        	$this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
40
+        }
37 41
         return $rules;
38 42
     }
39 43
 }
Please login to merge, or discard this patch.
src/TSSFunction/Template.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -17,6 +17,9 @@
 block discarded – undo
17 17
 		$this->xPath = $xPath;
18 18
 	}
19 19
 
20
+	/**
21
+	 * @param integer $index
22
+	 */
20 23
 	private function readArray($array, $index) {
21 24
 		return isset($array[$index]) ? $array[$index] : null;
22 25
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,13 +25,18 @@  discard block
 block discarded – undo
25 25
 		$selector = $this->readArray($args, 1);
26 26
 		$tss = $this->readArray($args, 2);
27 27
 
28
-		if (trim($args[0])[0] === '<') $xml = $args[0];
29
-		else $xml = $this->filePath->getFilePath($args[0]);
28
+		if (trim($args[0])[0] === '<') {
29
+			$xml = $args[0];
30
+		} else {
31
+			$xml = $this->filePath->getFilePath($args[0]);
32
+		}
30 33
 
31 34
 		$newTemplate = new \Transphporm\Builder($xml, $tss ? $this->filePath->getFilePath($tss) : null);
32 35
 
33 36
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
34
-		if ($selector != '') return $this->templateSubsection($doc, $selector);
37
+		if ($selector != '') {
38
+			return $this->templateSubsection($doc, $selector);
39
+		}
35 40
 
36 41
 		return $this->getTemplateContent($doc, $tss);
37 42
 
@@ -62,7 +67,9 @@  discard block
 block discarded – undo
62 67
 
63 68
 	private function getClonedElement($node, $tss) {
64 69
 		$clone = $node->cloneNode(true);
65
-		if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate');
70
+		if ($tss != null && $clone instanceof \DomElement) {
71
+			$clone->setAttribute('transphporm', 'includedtemplate');
72
+		}
66 73
 		return $clone;
67 74
 	}
68 75
 }
Please login to merge, or discard this patch.
src/FilePath.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 namespace Transphporm;
3 3
 
4 4
 class FilePath {
5
-    private $baseDir;
6
-    private $cwd;
5
+	private $baseDir;
6
+	private $cwd;
7 7
 
8
-    public function __construct(&$baseDir, $customBase = null) {
9
-        $this->baseDir = &$baseDir;
10
-        if ($customBase === null) $this->customBase = getcwd();
11
-        else $this->customBase = rtrim($customBase, '/');
12
-    }
8
+	public function __construct(&$baseDir, $customBase = null) {
9
+		$this->baseDir = &$baseDir;
10
+		if ($customBase === null) $this->customBase = getcwd();
11
+		else $this->customBase = rtrim($customBase, '/');
12
+	}
13 13
 
14
-    public function getFilePath($filePath = "") {
14
+	public function getFilePath($filePath = "") {
15 15
 		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16 16
 		else return $this->baseDir . $filePath;
17 17
 	}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     }
13 13
 
14 14
     public function getFilePath($filePath = "") {
15
-		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16
-		else return $this->baseDir . $filePath;
15
+		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase.$filePath;
16
+		else return $this->baseDir.$filePath;
17 17
 	}
18 18
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,12 +7,18 @@
 block discarded – undo
7 7
 
8 8
     public function __construct(&$baseDir, $customBase = null) {
9 9
         $this->baseDir = &$baseDir;
10
-        if ($customBase === null) $this->customBase = getcwd();
11
-        else $this->customBase = rtrim($customBase, '/');
10
+        if ($customBase === null) {
11
+        	$this->customBase = getcwd();
12
+        } else {
13
+        	$this->customBase = rtrim($customBase, '/');
14
+        }
12 15
     }
13 16
 
14 17
     public function getFilePath($filePath = "") {
15
-		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16
-		else return $this->baseDir . $filePath;
18
+		if (isset($filePath[0]) && $filePath[0] == "/") {
19
+			return $this->customBase . $filePath;
20
+		} else {
21
+			return $this->baseDir . $filePath;
22
+		}
17 23
 	}
18 24
 }
Please login to merge, or discard this patch.