@@ -6,7 +6,7 @@ |
||
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 | } |
@@ -6,13 +6,13 @@ |
||
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 | } |
@@ -6,18 +6,18 @@ |
||
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 | } |
@@ -7,5 +7,5 @@ |
||
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 | } |
@@ -6,14 +6,14 @@ |
||
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 | } |
@@ -7,48 +7,48 @@ |
||
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 | } |
@@ -6,39 +6,39 @@ |
||
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 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | * @version 1.2 */ |
7 | 7 | namespace Transphporm; |
8 | 8 | class RunException extends \Exception { |
9 | - public function __construct($operationType, $operationName, \Exception $previous) { |
|
10 | - $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\''; |
|
9 | + public function __construct($operationType, $operationName, \Exception $previous) { |
|
10 | + $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\''; |
|
11 | 11 | |
12 | - parent::__construct($message, 0, $previous); |
|
13 | - } |
|
12 | + parent::__construct($message, 0, $previous); |
|
13 | + } |
|
14 | 14 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | namespace Transphporm; |
8 | 8 | class RunException extends \Exception { |
9 | 9 | public function __construct($operationType, $operationName, \Exception $previous) { |
10 | - $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\''; |
|
10 | + $message = 'TSS Error: Problem carrying out '.$operationType.' \''.$operationName.'\''; |
|
11 | 11 | |
12 | 12 | parent::__construct($message, 0, $previous); |
13 | 13 | } |
@@ -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 |