Completed
Pull Request — master (#175)
by Tom
01:56
created
src/TSSFunction/Json.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm\TSSFunction;
8 8
 class Json implements \Transphporm\TSSFunction {
9
-    private $filePath;
9
+	private $filePath;
10 10
 
11
-    public function __construct(\Transphporm\FilePath $filePath) {
12
-        $this->filePath = $filePath;
13
-    }
11
+	public function __construct(\Transphporm\FilePath $filePath) {
12
+		$this->filePath = $filePath;
13
+	}
14 14
 
15
-    public function run(array $args, \DomElement $element = null) {
16
-        $json = $args[0];
15
+	public function run(array $args, \DomElement $element = null) {
16
+		$json = $args[0];
17 17
 
18
-        if ($this->isJsonFile($json)) {
19
-            $path = $this->filePath->getFilePath($json);
20
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
21
-            $json = file_get_contents($path);
22
-        }
18
+		if ($this->isJsonFile($json)) {
19
+			$path = $this->filePath->getFilePath($json);
20
+			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
21
+			$json = file_get_contents($path);
22
+		}
23 23
 
24
-        $map = json_decode($json, true);
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
-        return $map;
29
-    }
28
+		return $map;
29
+	}
30 30
 
31
-    private function isJsonFile($json) {
32
-        return trim($json)[0] != '{' && trim($json)[0] != '[';
33
-    }
31
+	private function isJsonFile($json) {
32
+		return trim($json)[0] != '{' && trim($json)[0] != '[';
33
+	}
34 34
 }
Please login to merge, or discard this patch.
src/TSSCache.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm;
8 8
 class TSSCache {
9
-    private $cache;
10
-    private $prefix;
9
+	private $cache;
10
+	private $prefix;
11 11
 
12
-    public function __construct(Cache $cache, $prefix) {
13
-        $this->cache = $cache;
14
-        $this->prefix = $prefix;
15
-    }
12
+	public function __construct(Cache $cache, $prefix) {
13
+		$this->cache = $cache;
14
+		$this->prefix = $prefix;
15
+	}
16 16
 
17 17
 	private function getRulesFromCache($file) {
18 18
 		//The cache for the key: the filename and template prefix
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
34 34
 	}
35 35
 
36
-    public function load($tss) {
37
-        return $this->getRulesFromCache($tss);
38
-    }
36
+	public function load($tss) {
37
+		return $this->getRulesFromCache($tss);
38
+	}
39 39
 
40
-    public function write($file, $rules, $imports = []) {
41
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
42
-        return $rules;
43
-    }
40
+	public function write($file, $rules, $imports = []) {
41
+		if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
42
+		return $rules;
43
+	}
44 44
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/Attr.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm\Property\ContentPseudo;
8 8
 class Attr implements \Transphporm\Property\ContentPseudo {
9
-    public function run($value, $pseudoArgs, $element) {
10
-        $element->setAttribute($pseudoArgs, implode('', $value));
11
-    }
9
+	public function run($value, $pseudoArgs, $element) {
10
+		$element->setAttribute($pseudoArgs, implode('', $value));
11
+	}
12 12
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/Headers.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm\Property\ContentPseudo;
8 8
 class Headers implements \Transphporm\Property\ContentPseudo {
9
-    private $headers;
9
+	private $headers;
10 10
 
11
-    public function __construct(&$headers) {
11
+	public function __construct(&$headers) {
12 12
 		$this->headers = &$headers;
13 13
 	}
14 14
 
15
-    public function run($value, $pseudoArgs, $element) {
16
-        $this->headers[] = [$pseudoArgs, implode('', $value)];
17
-    }
15
+	public function run($value, $pseudoArgs, $element) {
16
+		$this->headers[] = [$pseudoArgs, implode('', $value)];
17
+	}
18 18
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo/BeforeAfter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm\Property\ContentPseudo;
8 8
 class BeforeAfter implements \Transphporm\Property\ContentPseudo {
9
-    private $insertLocation;
10
-    private $content;
9
+	private $insertLocation;
10
+	private $content;
11 11
 
12
-    public function __construct($insertLocation, \Transphporm\Property\Content $content) {
13
-        $this->insertLocation = $insertLocation;
12
+	public function __construct($insertLocation, \Transphporm\Property\Content $content) {
13
+		$this->insertLocation = $insertLocation;
14 14
 		$this->content = $content;
15 15
 	}
16 16
 
17
-    public function run($value, $pseudoArgs, $element) {
18
-        foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
17
+	public function run($value, $pseudoArgs, $element) {
18
+		foreach ($this->content->getNode($value, $element->ownerDocument) as $node) {
19 19
 			if ($this->insertLocation === "before") $element->insertBefore($node, $element->firstChild);
20
-            else if ($this->insertLocation === "after") $element->appendChild($node);
20
+			else if ($this->insertLocation === "after") $element->appendChild($node);
21 21
 		}
22
-    }
22
+	}
23 23
 }
Please login to merge, or discard this patch.
src/Property/ContentPseudo.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
  namespace Transphporm\Property;
8 8
 
9 9
 interface ContentPseudo {
10
-    public function run($value, $pseudoArgs, $element);
10
+	public function run($value, $pseudoArgs, $element);
11 11
 }
Please login to merge, or discard this patch.
src/Exception.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
  namespace Transphporm;
8 8
 class Exception extends \Exception {
9
-    const PROPERTY = 'property';
10
-    const TSS_FUNCTION = 'function';
11
-    const PSEUDO = 'pseudo';
12
-    const FORMATTER = 'formatter';
9
+	const PROPERTY = 'property';
10
+	const TSS_FUNCTION = 'function';
11
+	const PSEUDO = 'pseudo';
12
+	const FORMATTER = 'formatter';
13 13
 
14
-    public function __construct(RunException $runException, $file, $line) {
15
-        $message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
14
+	public function __construct(RunException $runException, $file, $line) {
15
+		$message = $runException->getMessage() . ' on Line ' . $line . ' of ' . ($file === null ? 'tss' : $file);
16 16
 
17
-        parent::__construct($message, 0, $runException->getPrevious());
18
-    }
17
+		parent::__construct($message, 0, $runException->getPrevious());
18
+	}
19 19
 }
Please login to merge, or discard this patch.
src/TSSValidator.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,48 +7,48 @@
 block discarded – undo
7 7
  namespace Transphporm;
8 8
 use Transphporm\Parser\Tokenizer;
9 9
 class TSSValidator {
10
-    private $error;
10
+	private $error;
11 11
 
12
-    public function validate($tss) {
13
-        $this->error = null;
14
-        $tokens = $this->tokenize($tss);
12
+	public function validate($tss) {
13
+		$this->error = null;
14
+		$tokens = $this->tokenize($tss);
15 15
 
16
-        foreach ($tokens as $token)
17
-            if (!$this->validateRule($token)) return false;
16
+		foreach ($tokens as $token)
17
+			if (!$this->validateRule($token)) return false;
18 18
 
19
-        return true;
20
-    }
19
+		return true;
20
+	}
21 21
 
22
-    public function getLastError() {
23
-        return $this->error;
24
-    }
22
+	public function getLastError() {
23
+		return $this->error;
24
+	}
25 25
 
26
-    private function validateRule($token) {
27
-        if ($token['type'] !== Tokenizer::OPEN_BRACE) return true;
26
+	private function validateRule($token) {
27
+		if ($token['type'] !== Tokenizer::OPEN_BRACE) return true;
28 28
 
29
-        return $this->checkBraces($token) && $this->checkSemicolons($token)
30
-            && $this->checkParenthesis($token);
31
-    }
29
+		return $this->checkBraces($token) && $this->checkSemicolons($token)
30
+			&& $this->checkParenthesis($token);
31
+	}
32 32
 
33
-    private function checkBraces($token) {
34
-        return strpos($token['string'], '{') === false;
35
-    }
33
+	private function checkBraces($token) {
34
+		return strpos($token['string'], '{') === false;
35
+	}
36 36
 
37
-    private function checkSemicolons($braceToken) {
38
-        $splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON);
39
-        array_shift($splitTokens); array_pop($splitTokens);
40
-        foreach ($splitTokens as $tokens)
41
-            if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
37
+	private function checkSemicolons($braceToken) {
38
+		$splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON);
39
+		array_shift($splitTokens); array_pop($splitTokens);
40
+		foreach ($splitTokens as $tokens)
41
+			if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
42 42
 
43
-        return true;
44
-    }
43
+		return true;
44
+	}
45 45
 
46
-    private function checkParenthesis($token) {
47
-        return substr_count($token['string'], '(') === substr_count($token['string'], ')');
48
-    }
46
+	private function checkParenthesis($token) {
47
+		return substr_count($token['string'], '(') === substr_count($token['string'], ')');
48
+	}
49 49
 
50
-    private function tokenize($tss) {
51
-        if (is_file($tss)) $tss = file_get_contents($tss);
52
-        return (new Parser\Tokenizer($tss))->getTokens();
53
-    }
50
+	private function tokenize($tss) {
51
+		if (is_file($tss)) $tss = file_get_contents($tss);
52
+		return (new Parser\Tokenizer($tss))->getTokens();
53
+	}
54 54
 }
Please login to merge, or discard this patch.
src/Parser/TokenFilterIterator.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
  * @version         1.2                                                             */
7 7
 namespace Transphporm\Parser;
8 8
 class TokenFilterIterator implements \Iterator {
9
-    private $ignore;
10
-    private $tokens;
9
+	private $ignore;
10
+	private $tokens;
11 11
 
12
-    public function __construct(Tokens $tokens, array $ignore) {
13
-        $this->ignore = $ignore;
14
-        $this->tokens = $tokens;
15
-    }
12
+	public function __construct(Tokens $tokens, array $ignore) {
13
+		$this->ignore = $ignore;
14
+		$this->tokens = $tokens;
15
+	}
16 16
 
17
-    public function current() {
18
-        return $this->tokens->current();
19
-    }
17
+	public function current() {
18
+		return $this->tokens->current();
19
+	}
20 20
 
21
-    public function key() {
22
-        return $this->tokens->key();
23
-    }
21
+	public function key() {
22
+		return $this->tokens->key();
23
+	}
24 24
 
25
-    public function valid() {
26
-        return $this->tokens->valid();
27
-    }
25
+	public function valid() {
26
+		return $this->tokens->valid();
27
+	}
28 28
 
29
-    public function next() {
30
-        do {
31
-            $this->tokens->next();
32
-        }
33
-        while ($this->shouldContinue());
34
-    }
29
+	public function next() {
30
+		do {
31
+			$this->tokens->next();
32
+		}
33
+		while ($this->shouldContinue());
34
+	}
35 35
 
36
-    public function rewind() {
37
-        $this->tokens->rewind();
38
-        while ($this->shouldContinue()) $this->tokens->next();
39
-    }
36
+	public function rewind() {
37
+		$this->tokens->rewind();
38
+		while ($this->shouldContinue()) $this->tokens->next();
39
+	}
40 40
 
41
-    private function shouldContinue() {
42
-        return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);
43
-    }
41
+	private function shouldContinue() {
42
+		return $this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore);
43
+	}
44 44
 }
Please login to merge, or discard this patch.