@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | $this->fileName = $fileName; |
| 17 | 17 | $this->filePath = $filePath; |
| 18 | 18 | $this->cache = $cache; |
| 19 | - $this->time = $time ?? time(); |
|
| 20 | - $this->cacheName = $this->fileName; |
|
| 19 | + $this->time = $time ?? time(); |
|
| 20 | + $this->cacheName = $this->fileName; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | private function getRulesFromCache($file) { |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //write the sheet to cache |
| 77 | - public function write($rules, $imports = []) { |
|
| 77 | + public function write($rules, $imports = []) { |
|
| 78 | 78 | |
| 79 | 79 | $existing = $this->cache->load($this->fileName, filemtime($this->fileName)); |
| 80 | 80 | if (isset($existing['import']) && empty($imports)) $imports = $existing['import']; |
| 81 | 81 | $this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]); |
| 82 | 82 | |
| 83 | 83 | return $rules; |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - //Gets the minimum update-frequency for a sheet's rules |
|
| 86 | + //Gets the minimum update-frequency for a sheet's rules |
|
| 87 | 87 | private function getMinUpdateFreq($rules) { |
| 88 | 88 | $min = \PHP_INT_MAX; |
| 89 | 89 | |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | namespace Transphporm\SheetLoader; |
| 8 | 8 | //Separates out TSS file loading/caching from parsing |
| 9 | 9 | class SheetLoader { |
| 10 | - private $tss; |
|
| 11 | - private $filePath; |
|
| 12 | - private $time; |
|
| 13 | - private $import = []; |
|
| 14 | - |
|
| 15 | - public function __construct(\Transphporm\Cache $cache, \Transphporm\FilePath $filePath, TSSRules $tss, $time) { |
|
| 16 | - $this->cache = $cache; |
|
| 17 | - $this->filePath = $filePath; |
|
| 18 | - $this->tss = $tss; |
|
| 19 | - $this->time = $time ?? time(); |
|
| 20 | - } |
|
| 10 | + private $tss; |
|
| 11 | + private $filePath; |
|
| 12 | + private $time; |
|
| 13 | + private $import = []; |
|
| 14 | + |
|
| 15 | + public function __construct(\Transphporm\Cache $cache, \Transphporm\FilePath $filePath, TSSRules $tss, $time) { |
|
| 16 | + $this->cache = $cache; |
|
| 17 | + $this->filePath = $filePath; |
|
| 18 | + $this->tss = $tss; |
|
| 19 | + $this->time = $time ?? time(); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | 22 | //Allows controlling whether any updates are required to the template |
| 23 | 23 | //e.g. return false |
@@ -100,14 +100,14 @@ |
||
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | private function getProperties($tokens) { |
| 103 | - $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON); |
|
| 103 | + $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON); |
|
| 104 | 104 | |
| 105 | - $return = []; |
|
| 106 | - foreach ($rules as $rule) { |
|
| 107 | - $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read(); |
|
| 108 | - $return[$name] = $rule->from(Tokenizer::COLON)->trim(); |
|
| 109 | - } |
|
| 105 | + $return = []; |
|
| 106 | + foreach ($rules as $rule) { |
|
| 107 | + $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read(); |
|
| 108 | + $return[$name] = $rule->from(Tokenizer::COLON)->trim(); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - return $return; |
|
| 112 | - } |
|
| 111 | + return $return; |
|
| 112 | + } |
|
| 113 | 113 | } |