@@ -2,5 +2,5 @@ |
||
2 | 2 | namespace Transphporm\Property; |
3 | 3 | |
4 | 4 | interface ContentPseudo { |
5 | - public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher); |
|
5 | + public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher); |
|
6 | 6 | } |
@@ -7,44 +7,44 @@ |
||
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 | - private function validateRule($token) { |
|
23 | - if ($token['type'] !== Tokenizer::OPEN_BRACE) return true; |
|
22 | + private function validateRule($token) { |
|
23 | + if ($token['type'] !== Tokenizer::OPEN_BRACE) return true; |
|
24 | 24 | |
25 | - return $this->checkBraces($token) && $this->checkSemicolons($token) |
|
26 | - && $this->checkParenthesis($token); |
|
27 | - } |
|
25 | + return $this->checkBraces($token) && $this->checkSemicolons($token) |
|
26 | + && $this->checkParenthesis($token); |
|
27 | + } |
|
28 | 28 | |
29 | - private function checkBraces($token) { |
|
30 | - return strpos($token['string'], '{') === false; |
|
31 | - } |
|
29 | + private function checkBraces($token) { |
|
30 | + return strpos($token['string'], '{') === false; |
|
31 | + } |
|
32 | 32 | |
33 | - private function checkSemicolons($braceToken) { |
|
34 | - $splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON); |
|
35 | - array_shift($splitTokens); array_pop($splitTokens); |
|
36 | - foreach ($splitTokens as $tokens) |
|
37 | - if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false; |
|
33 | + private function checkSemicolons($braceToken) { |
|
34 | + $splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON); |
|
35 | + array_shift($splitTokens); array_pop($splitTokens); |
|
36 | + foreach ($splitTokens as $tokens) |
|
37 | + if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false; |
|
38 | 38 | |
39 | - return true; |
|
40 | - } |
|
39 | + return true; |
|
40 | + } |
|
41 | 41 | |
42 | - private function checkParenthesis($token) { |
|
43 | - return substr_count($token['string'], '(') === substr_count($token['string'], ')'); |
|
44 | - } |
|
42 | + private function checkParenthesis($token) { |
|
43 | + return substr_count($token['string'], '(') === substr_count($token['string'], ')'); |
|
44 | + } |
|
45 | 45 | |
46 | - private function tokenize($tss) { |
|
47 | - if (is_file($tss)) $tss = file_get_contents($tss); |
|
48 | - return (new Parser\Tokenizer($tss))->getTokens(); |
|
49 | - } |
|
46 | + private function tokenize($tss) { |
|
47 | + if (is_file($tss)) $tss = file_get_contents($tss); |
|
48 | + return (new Parser\Tokenizer($tss))->getTokens(); |
|
49 | + } |
|
50 | 50 | } |
@@ -6,13 +6,13 @@ discard block |
||
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 |
||
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 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | * @version 1.2 */ |
7 | 7 | namespace Transphporm\Formatter; |
8 | 8 | class HTMLFormatter { |
9 | - private $templateFunction; |
|
9 | + private $templateFunction; |
|
10 | 10 | |
11 | - public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { |
|
12 | - $this->templateFunction = $templateFunction; |
|
13 | - } |
|
11 | + public function __construct(\Transphporm\TSSFunction\Template $templateFunction) { |
|
12 | + $this->templateFunction = $templateFunction; |
|
13 | + } |
|
14 | 14 | |
15 | - public function html($val) { |
|
15 | + public function html($val) { |
|
16 | 16 | return $this->templateFunction->run(['<template>' . $val . '</template>']); |
17 | 17 | } |
18 | 18 |