Completed
Push — master ( e2c192...f9a7a2 )
by Tom
9s
created
src/Builder.php 1 patch
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		$this->cache = new Cache(new \ArrayObject());
27 27
 
28 28
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
29
-		foreach ($modules as $module) $this->loadModule(new $module);
29
+		foreach ($modules as $module) {
30
+			$this->loadModule(new $module);
31
+		}
30 32
 	}
31 33
 
32 34
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 		$data = new FunctionSet($elementData);
48 50
 		$config = new Config($data, $elementData, new Hook\Formatter(), $headers, $this->baseDir);
49 51
 
50
-		foreach ($this->modules as $module) $module->load($config);
52
+		foreach ($this->modules as $module) {
53
+			$module->load($config);
54
+		}
51 55
 
52 56
 		$cachedOutput = $this->loadTemplate();
53 57
 		//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
@@ -67,7 +71,9 @@  discard block
 block discarded – undo
67 71
 		$rules = $this->getRules($template, $valueParser);
68 72
 
69 73
 		foreach ($rules as $rule) {
70
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $valueParser, $config, $functionSet);
74
+			if ($rule->shouldRun($this->time)) {
75
+				$this->executeTssRule($rule, $template, $valueParser, $config, $functionSet);
76
+			}
71 77
 		}
72 78
 	}
73 79
 
@@ -92,8 +98,9 @@  discard block
 block discarded – undo
92 98
 		if (trim($this->template)[0] !== '<') {
93 99
 			$xml = $this->cache->load($this->template, filemtime($this->template));
94 100
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
101
+		} else {
102
+			return ['body' => $this->template, 'headers' => []];
95 103
 		}
96
-		else return ['body' => $this->template, 'headers' => []];
97 104
 	}
98 105
 
99 106
 	//Load the TSS rules either from a file or as a string
@@ -107,10 +114,14 @@  discard block
 block discarded – undo
107 114
 			$key = $this->tss . $template->getPrefix() . $this->baseDir;
108 115
 			//Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet
109 116
 			$rules = $this->cache->load($key, filemtime($this->tss));
110
-			if (!$rules) return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $valueParser, $template->getPrefix()))->parse());
111
-			else return $rules;
117
+			if (!$rules) {
118
+				return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $valueParser, $template->getPrefix()))->parse());
119
+			} else {
120
+				return $rules;
121
+			}
122
+		} else {
123
+			return (new Parser\Sheet($this->tss, $this->baseDir, $valueParser, $template->getPrefix()))->parse();
112 124
 		}
113
-		else return (new Parser\Sheet($this->tss, $this->baseDir, $valueParser, $template->getPrefix()))->parse();
114 125
 	}
115 126
 
116 127
 	public function setCache(\ArrayAccess $cache) {
Please login to merge, or discard this patch.
src/TSSFunction/Json.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\TSSFunction;
3 3
 class Json implements \Transphporm\TSSFunction {
4
-    private $baseDir;
4
+	private $baseDir;
5 5
 
6
-    public function __construct(&$baseDir) {
7
-        $this->baseDir = &$baseDir;
8
-    }
6
+	public function __construct(&$baseDir) {
7
+		$this->baseDir = &$baseDir;
8
+	}
9 9
 
10
-    public function run(array $args, \DomElement $element = null) {
11
-        $json = $args[0];
10
+	public function run(array $args, \DomElement $element = null) {
11
+		$json = $args[0];
12 12
 
13
-        if (trim($json)[0] != '{') {
14
-            $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
-            $json = file_get_contents($json);
17
-        }
13
+		if (trim($json)[0] != '{') {
14
+			$path = $this->baseDir . $json;
15
+			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
+			$json = file_get_contents($json);
17
+		}
18 18
 
19
-        $map = json_decode($json, true);
19
+		$map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+		if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
22 22
 
23
-        return $map;
24
-    }
23
+		return $map;
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
         $json = $args[0];
12 12
 
13 13
         if (trim($json)[0] != '{') {
14
-            $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
14
+            $path = $this->baseDir.$json;
15
+            if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path);
16 16
             $json = file_get_contents($json);
17 17
         }
18 18
 
19 19
         $map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+        if (!is_array($map)) throw new \Exception('Could not decode json: '.json_last_error_msg());
22 22
 
23 23
         return $map;
24 24
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,17 @@
 block discarded – undo
12 12
 
13 13
         if (trim($json)[0] != '{') {
14 14
             $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
15
+            if (!file_exists($path)) {
16
+            	throw new \Exception('File does not exist at: ' . $path);
17
+            }
16 18
             $json = file_get_contents($json);
17 19
         }
18 20
 
19 21
         $map = json_decode($json, true);
20 22
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
23
+        if (!is_array($map)) {
24
+        	throw new \Exception('Could not decode json: ' . json_last_error_msg());
25
+        }
22 26
 
23 27
         return $map;
24 28
     }
Please login to merge, or discard this patch.
src/Pseudo/Attribute.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	public function match($pseudo, \DomElement $element) {
16 16
 
17 17
 		$pos = strpos($pseudo, '[');
18
-		if ($pos === false) return true;
18
+		if ($pos === false) {
19
+			return true;
20
+		}
19 21
 
20 22
 		$name = substr($pseudo, 0, $pos);
21
-		if (!$this->functionSet->hasFunction($name)) return true;
23
+		if (!$this->functionSet->hasFunction($name)) {
24
+			return true;
25
+		}
22 26
 
23 27
 		$bracketMatcher = new \Transphporm\Parser\BracketMatcher($pseudo);
24 28
 		$criteria = $bracketMatcher->match('[', ']');
@@ -28,11 +32,14 @@  discard block
 block discarded – undo
28 32
 		$criteria = $name . '(' . $criteria;
29 33
 
30 34
 		$pos = strpos($pseudo, '!');
31
-		if ($pos === false) $pos = strpos($pseudo, '=');
35
+		if ($pos === false) {
36
+			$pos = strpos($pseudo, '=');
37
+		}
32 38
 		if ($pos === false) {
33 39
 			$criteria .= ')=true';
40
+		} else {
41
+			$criteria = substr_replace($criteria, ')', $pos, 0);
34 42
 		}
35
-		else $criteria = substr_replace($criteria, ')', $pos, 0);
36 43
 
37 44
 		return $valueParser->parse($criteria, $element)[0];
38 45
 	}
Please login to merge, or discard this patch.