Completed
Pull Request — master (#12)
by Arthur
02:10
created
src/WebThumbnailer/Application/CacheManager.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * Thumbnails image cache.
28 28
      */
29
-    const TYPE_THUMB  = 'thumb';
29
+    const TYPE_THUMB = 'thumb';
30 30
     /**
31 31
      * Finder cache.
32 32
      */
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             self::rebuildCacheFolders();
62 62
             return self::getCachePath($type, true);
63 63
         } elseif (!$path) {
64
-            throw new IOException('Cache folders are not writable: '. $cache);
64
+            throw new IOException('Cache folders are not writable: '.$cache);
65 65
         }
66 66
         return $path;
67 67
     }
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
         self::createDomainThumbCacheFolder($domainHash, $type);
95 95
         $domainFolder = FileUtils::getPath(self::getCachePath($type), $domainHash);
96 96
         if ($type === self::TYPE_THUMB) {
97
-            $suffix = $width . $height . ($crop ? '1' : '0') . (self::PATH_TYPE[$pathType]) .'.jpg';
97
+            $suffix = $width.$height.($crop ? '1' : '0').(self::PATH_TYPE[$pathType]).'.jpg';
98 98
         } else {
99
-            $suffix = $width . $height;
99
+            $suffix = $width.$height;
100 100
         }
101
-        return $domainFolder . self::getThumbFilename($url) . $suffix;
101
+        return $domainFolder.self::getThumbFilename($url).$suffix;
102 102
     }
103 103
 
104 104
     /**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     public static function isCacheValid($cacheFile, $domain, $type)
117 117
     {
118 118
         $out = false;
119
-        $cacheDuration = ConfigManager::get('settings.cache_duration', 3600*24*31);
119
+        $cacheDuration = ConfigManager::get('settings.cache_duration', 3600 * 24 * 31);
120 120
 
121 121
         if (is_readable($cacheFile)
122 122
             && ($cacheDuration < 0 || (time() - filemtime($cacheFile)) < $cacheDuration)
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
     protected static function createDomainThumbCacheFolder($domain, $type)
139 139
     {
140 140
         $cachePath = self::getCachePath($type);
141
-        $domainFolder = $cachePath . $domain;
141
+        $domainFolder = $cachePath.$domain;
142 142
         if (!file_exists($domainFolder)) {
143 143
             mkdir($domainFolder, 0775, false);
144
-            touch($domainFolder . '/' . self::$CLEAN_FILE);
144
+            touch($domainFolder.'/'.self::$CLEAN_FILE);
145 145
         }
146 146
         self::createHtaccessFile($cachePath, $type === self::TYPE_THUMB);
147 147
     }
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
      */
156 156
     protected static function createHtaccessFile($path, $allowed = false)
157 157
     {
158
-        $htaccessFile = $path . '.htaccess';
158
+        $htaccessFile = $path.'.htaccess';
159 159
         if (file_exists($htaccessFile)) {
160 160
             return;
161 161
         }
162
-        $template = new \Text_Template(FileUtils::RESOURCES_PATH . 'htaccess_template');
162
+        $template = new \Text_Template(FileUtils::RESOURCES_PATH.'htaccess_template');
163 163
         $template->setVar([
164 164
             'new_all' => $allowed ? 'granted' : 'denied',
165 165
             'old_allow' => $allowed ? 'all' : 'none',
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     protected static function checkCacheType($type)
192 192
     {
193 193
         if ($type != self::TYPE_THUMB && $type != self::TYPE_FINDER) {
194
-            throw new CacheException('Unknown cache type '. $type);
194
+            throw new CacheException('Unknown cache type '.$type);
195 195
         }
196 196
     }
197 197
 
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
     protected static function rebuildCacheFolders()
202 202
     {
203 203
         $mainFolder = ConfigManager::get('settings.path.cache', 'cache/');
204
-        if (! is_dir($mainFolder)) {
204
+        if (!is_dir($mainFolder)) {
205 205
             mkdir($mainFolder, 0755);
206 206
         }
207
-        if (! is_dir($mainFolder.self::TYPE_THUMB)) {
207
+        if (!is_dir($mainFolder.self::TYPE_THUMB)) {
208 208
             mkdir($mainFolder.self::TYPE_THUMB, 0755);
209 209
         }
210
-        if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) {
211
-            touch($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep');
210
+        if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) {
211
+            touch($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep');
212 212
         }
213
-        if (! is_dir($mainFolder.self::TYPE_FINDER)) {
214
-            mkdir($mainFolder . self::TYPE_FINDER, 0755);
213
+        if (!is_dir($mainFolder.self::TYPE_FINDER)) {
214
+            mkdir($mainFolder.self::TYPE_FINDER, 0755);
215 215
         }
216
-        if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) {
216
+        if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) {
217 217
             touch($mainFolder.self::TYPE_FINDER.DIRECTORY_SEPARATOR.'.gitkeep');
218 218
         }
219 219
     }
Please login to merge, or discard this patch.