@@ -102,14 +102,14 @@ |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | private function getProperties($tokens) { |
| 105 | - $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON); |
|
| 105 | + $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON); |
|
| 106 | 106 | |
| 107 | - $return = []; |
|
| 108 | - foreach ($rules as $rule) { |
|
| 109 | - $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read(); |
|
| 110 | - $return[$name] = $rule->from(Tokenizer::COLON)->trim(); |
|
| 111 | - } |
|
| 107 | + $return = []; |
|
| 108 | + foreach ($rules as $rule) { |
|
| 109 | + $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read(); |
|
| 110 | + $return[$name] = $rule->from(Tokenizer::COLON)->trim(); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - return $return; |
|
| 114 | - } |
|
| 113 | + return $return; |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | * @version 1.0 */ |
| 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 | } |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Transphporm; |
| 3 | 3 | class RunException extends \Exception { |
| 4 | - public function __construct($operationType, $operationName, \Exception $previous) { |
|
| 5 | - $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\''; |
|
| 4 | + public function __construct($operationType, $operationName, \Exception $previous) { |
|
| 5 | + $message = 'TSS Error: Problem carrying out ' . $operationType . ' \'' . $operationName . '\''; |
|
| 6 | 6 | |
| 7 | - parent::__construct($message, 0, $previous); |
|
| 8 | - } |
|
| 7 | + parent::__construct($message, 0, $previous); |
|
| 8 | + } |
|
| 9 | 9 | } |
@@ -1,14 +1,14 @@ |
||
| 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 | } |
@@ -1,13 +1,13 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -1,29 +1,29 @@ |
||
| 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 | } |
@@ -1,13 +1,13 @@ |
||
| 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 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | private $pseudo; |
| 11 | 11 | private $depth; |
| 12 | 12 | private $index; |
| 13 | - private $file; |
|
| 13 | + private $file; |
|
| 14 | 14 | private $line; |
| 15 | 15 | private $properties = []; |
| 16 | 16 | private $lastRun = 0; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $this->pseudo = $pseudo; |
| 27 | 27 | $this->depth = $depth; |
| 28 | 28 | $this->index = $index; |
| 29 | - $this->file = $file; |
|
| 29 | + $this->file = $file; |
|
| 30 | 30 | $this->line = $line; |
| 31 | 31 | $this->properties = $properties; |
| 32 | 32 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | private function getTemplateContent($newNode, $tss) { |
| 41 | 41 | $result = []; |
| 42 | 42 | foreach ($newNode->childNodes as $node) { |
| 43 | - if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss); |
|
| 43 | + if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss); |
|
| 44 | 44 | else $result[] = $this->getClonedElement($node, $tss); |
| 45 | 45 | } |
| 46 | 46 | return $result; |