Completed
Pull Request — master (#175)
by Tom
05:04 queued 04:06
created
src/Exception.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class Exception extends \Exception {
4
-    const PROPERTY = 'property';
5
-    const TSS_FUNCTION = 'function';
6
-    const PSEUDO = 'pseudo';
7
-    const FORMATTER = 'formatter';
4
+	const PROPERTY = 'property';
5
+	const TSS_FUNCTION = 'function';
6
+	const PSEUDO = 'pseudo';
7
+	const FORMATTER = 'formatter';
8 8
 
9
-    public function __construct(RunException $runException, $file, $line) {
10
-        $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
9
+	public function __construct(RunException $runException, $file, $line) {
10
+		$message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
11 11
 
12
-        parent::__construct($message, 0, $runException->getPrevious());
13
-    }
12
+		parent::__construct($message, 0, $runException->getPrevious());
13
+	}
14 14
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
     const FORMATTER = 'formatter';
8 8
 
9 9
     public function __construct(RunException $runException, $file, $line) {
10
-        $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
10
+        $message = $runException->getMessage().' on Line '.$line.' of '.($file === null ? 'tss' : $file);
11 11
 
12 12
         parent::__construct($message, 0, $runException->getPrevious());
13 13
     }
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/Json.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 
13 13
         if ($this->isJsonFile($json)) {
14 14
             $path = $this->filePath->getFilePath($json);
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
15
+            if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path);
16 16
             $json = file_get_contents($path);
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.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\TSSFunction;
3 3
 class Json implements \Transphporm\TSSFunction {
4
-    private $filePath;
4
+	private $filePath;
5 5
 
6
-    public function __construct(\Transphporm\FilePath $filePath) {
7
-        $this->filePath = $filePath;
8
-    }
6
+	public function __construct(\Transphporm\FilePath $filePath) {
7
+		$this->filePath = $filePath;
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 ($this->isJsonFile($json)) {
14
-            $path = $this->filePath->getFilePath($json);
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
-            $json = file_get_contents($path);
17
-        }
13
+		if ($this->isJsonFile($json)) {
14
+			$path = $this->filePath->getFilePath($json);
15
+			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
+			$json = file_get_contents($path);
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
 
26
-    private function isJsonFile($json) {
27
-        return trim($json)[0] != '{' && trim($json)[0] != '[';
28
-    }
26
+	private function isJsonFile($json) {
27
+		return trim($json)[0] != '{' && trim($json)[0] != '[';
28
+	}
29 29
 }
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 ($this->isJsonFile($json)) {
14 14
             $path = $this->filePath->getFilePath($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($path);
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/Parser/ValueResult.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,10 +31,11 @@
 block discarded – undo
31 31
 		];
32 32
 
33 33
 		if ($funcs[$this->mode] === 'concat' && is_numeric($newValue)
34
-			&& is_numeric($this->result[count($this->result)-1]))
35
-			$this->add($newValue);
36
-		else
37
-			$this->{$funcs[$this->mode]}($newValue);
34
+			&& is_numeric($this->result[count($this->result)-1])) {
35
+					$this->add($newValue);
36
+		} else {
37
+					$this->{$funcs[$this->mode]}($newValue);
38
+		}
38 39
 	}
39 40
 
40 41
 	public function arg($value) {
Please login to merge, or discard this patch.
src/Formatter/HTMLFormatter.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -7,6 +7,9 @@
 block discarded – undo
7 7
         $this->templateFunction = $templateFunction;
8 8
     }
9 9
 
10
+    /**
11
+     * @param string $val
12
+     */
10 13
     public function html($val) {
11 14
 		return $this->templateFunction->run(['<template>' . $val . '</template>']);
12 15
 	}
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\Formatter;
3 3
 class HTMLFormatter {
4
-    private $templateFunction;
4
+	private $templateFunction;
5 5
 
6
-    public function __construct(\Transphporm\TSSFunction\Template $templateFunction) {
7
-        $this->templateFunction = $templateFunction;
8
-    }
6
+	public function __construct(\Transphporm\TSSFunction\Template $templateFunction) {
7
+		$this->templateFunction = $templateFunction;
8
+	}
9 9
 
10
-    public function html($val) {
10
+	public function html($val) {
11 11
 		return $this->templateFunction->run(['<template>' . $val . '</template>']);
12 12
 	}
13 13
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
     }
9 9
 
10 10
     public function html($val) {
11
-		return $this->templateFunction->run(['<template>' . $val . '</template>']);
11
+		return $this->templateFunction->run(['<template>'.$val.'</template>']);
12 12
 	}
13 13
 
14 14
 	public function debug($val) {
15 15
 		ob_start();
16 16
 		var_dump($val);
17
-		return $this->html('<pre>' . ob_get_clean() . '</pre>');
17
+		return $this->html('<pre>'.ob_get_clean().'</pre>');
18 18
 	}
19 19
 }
Please login to merge, or discard this patch.
src/Module/Format.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
 	private function getLocale() {
17 17
 		if (is_array($this->locale)) return $this->locale;
18
-		else if (strlen($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);
18
+		else if (strlen($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);
20 20
 	}
21 21
 
22 22
 	public function load(\Transphporm\Config $config) {
Please login to merge, or discard this 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($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($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/Pseudo/Attribute.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
 namespace Transphporm\Pseudo;
8 8
 class Attribute implements \Transphporm\Pseudo {
9 9
 	public function match($name, $args, \DomElement $element) {
10
-		if (!($name === null || in_array($name, ['data', 'iteration', 'root'])))  return true;
10
+		if (!($name === null || in_array($name, ['data', 'iteration', 'root']))) {
11
+			return true;
12
+		}
11 13
 		return $args[0];
12 14
 	}
13 15
 }
Please login to merge, or discard this patch.
src/Cache.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
21 21
 		$key = md5($key);
22 22
 		if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) {
23 23
 			return $this->cache[$key]['content'];
24
+		} else {
25
+			return false;
24 26
 		}
25
-		else return false;
26 27
 	}
27 28
 }
28 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/Hook/Formatter.php 1 patch
Braces   +7 added lines, -4 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 format($value, $rules) {
17
-		if (!isset($rules['format'])) return $value;
17
+		if (!isset($rules['format'])) {
18
+			return $value;
19
+		}
18 20
 		$tokens = $rules['format'];
19 21
 
20 22
 		$functionName = $tokens->from(\Transphporm\Parser\Tokenizer::NAME, true)->read();
@@ -27,15 +29,16 @@  discard block
 block discarded – undo
27 29
 
28 30
 		try {
29 31
 			return $this->processFormat($options, $functionName, $value);
30
-		}
31
-		catch (\Exception $e) {
32
+		} catch (\Exception $e) {
32 33
 			throw new \Transphporm\RunException(\Transphporm\Exception::FORMATTER, $functionName, $e);
33 34
 		}
34 35
 	}
35 36
 
36 37
 	//TODO: Abstract all error reporting externally with a method for turning it on/off
37 38
 	private function assert($condition, $error) {
38
-		if (!$condition) throw new \Exception($error);
39
+		if (!$condition) {
40
+			throw new \Exception($error);
41
+		}
39 42
 	}
40 43
 
41 44
 	private function processFormat($format, $functionName, $value) {
Please login to merge, or discard this patch.