Completed
Push — master ( da7c37...06f4a4 )
by Tom
03:19
created
src/SheetLoader.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@  discard block
 block discarded – undo
7 7
 namespace Transphporm;
8 8
 //Separates out TSS file loading/caching from parsing
9 9
 class SheetLoader {
10
-    private $cache;
11
-    private $sheet;
12
-    private $time;
13
-    private $import = [];
14
-    private $cacheKey;
15
-    private $rules;
16
-    private $cacheName;
17
-
18
-    public function __construct(Cache $cache, FilePath $filePath, $tss, $time) {
19
-    	$this->cache = $cache;
20
-        $this->filePath = $filePath;
21
-        $this->tss = $tss;
22
-        $this->time = $time ?? time();
23
-        $this->cacheName = $tss;
24
-    }
10
+	private $cache;
11
+	private $sheet;
12
+	private $time;
13
+	private $import = [];
14
+	private $cacheKey;
15
+	private $rules;
16
+	private $cacheName;
17
+
18
+	public function __construct(Cache $cache, FilePath $filePath, $tss, $time) {
19
+		$this->cache = $cache;
20
+		$this->filePath = $filePath;
21
+		$this->tss = $tss;
22
+		$this->time = $time ?? time();
23
+		$this->cacheName = $tss;
24
+	}
25 25
 
26 26
 	private function getRulesFromCache($file) {
27 27
 		//Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	//write the sheet to cache
93
-    public function write($file, $rules, $imports = []) {
93
+	public function write($file, $rules, $imports = []) {
94 94
 		if (is_file($file)) {
95 95
 			$existing = $this->cache->load($file, filemtime($file));
96 96
 			if (isset($existing['import']) && empty($imports)) $imports = $existing['import'];
97 97
 			$this->cache->write($this->cacheName, ['rules' => $rules, 'import' => $imports, 'minFreq' => $this->getMinUpdateFreq($rules), 'ctime' => $this->time, 'cacheKey' => $this->cacheKey]);
98 98
 		}
99 99
 		return $rules;
100
-    }
100
+	}
101 101
 
102 102
 	public function processRules($template, \Transphporm\Config $config) {
103 103
 		$rules = $this->getRules($this->tss, $config->getCssToXpath(), $config->getValueParser());
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 	//Load the TSS
116 116
 	public function getRules($tss, $cssToXpath, $valueParser, $indexStart = 0) {
117 117
 		if (is_file($tss)) {
118
-    		//$rules = $this->cache->load($tss);
119
-    		$rules = $this->getRulesFromCache($tss)['rules'];
118
+			//$rules = $this->cache->load($tss);
119
+			$rules = $this->getRulesFromCache($tss)['rules'];
120 120
 			$this->filePath->addPath(dirname(realpath($tss)));
121 121
 			if (empty($rules)) $tss = file_get_contents($tss);
122 122
 			else return $rules;
123
-    	}
123
+		}
124 124
 		return $tss == null ? [] : (new Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $this))->parse($indexStart);
125 125
 	}
126 126
 	//Process a TSS rule e.g. `ul li {content: "foo"; format: bar}
Please login to merge, or discard this patch.