Passed
Push — master ( d2956c...9cde44 )
by Fran
03:15
created
src/base/Cache.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     private function saveTextToFile($data, $path, $absolute = false)
32 32
     {
33
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
33
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
34 34
         $filename = basename($absolutePath);
35 35
         Config::createDir(str_replace($filename, "", $absolutePath));
36 36
         if (false === file_put_contents($absolutePath, $data)) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
50 50
     {
51 51
         $data = null;
52
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
52
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
53 53
         if (file_exists($absolutePath)) {
54 54
             $data = file_get_contents($absolutePath);
55 55
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
67 67
     {
68
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
68
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
69 69
         $lasModificationDate = filemtime($absolutePath);
70 70
         return ($lasModificationDate + $expires <= time());
71 71
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 break;
89 89
             case Cache::GZIP:
90 90
                 // TODO implementar
91
-                if(function_exists('gzuncompress')) {
91
+                if (function_exists('gzuncompress')) {
92 92
                     $data = gzuncompress($data ?: '');
93 93
                 }
94 94
                 break;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 $data = Cache::transformData($data, Cache::GZIP);
114 114
                 break;
115 115
             case Cache::GZIP:
116
-                if(function_exists('gzcompress')) {
116
+                if (function_exists('gzcompress')) {
117 117
                     $data = gzcompress($data ?: '');
118 118
                 }
119 119
                 break;
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
146 146
     {
147 147
         $data = null;
148
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
148
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
149 149
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
150 150
                 $data = call_user_func($function);
151 151
                 $this->storeData($path, $data, $transform);
152
-            } else {
152
+            }else {
153 153
                 $data = $this->getDataFromFile($path, $transform);
154 154
             }
155 155
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     private static function checkAdminSite() {
163 163
         $isAdminRequest = false;
164 164
         $lastRequest = Security::getInstance()->getSessionKey("lastRequest");
165
-        if(null !== $lastRequest) {
165
+        if (null !== $lastRequest) {
166 166
             $url = str_replace(Request::getInstance()->getRootUrl(true), '', $lastRequest['url']);
167 167
             $isAdminRequest = preg_match('/^\/admin\//i', $url);
168 168
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     public static function needCache()
177 177
     {
178 178
         $needCache = false;
179
-        if(!self::checkAdminSite()) {
179
+        if (!self::checkAdminSite()) {
180 180
             $action = Security::getInstance()->getSessionKey("__CACHE__");
181 181
             if (null !== $action && array_key_exists("cache", $action) && $action["cache"] > 0) {
182 182
                 $needCache = $action["cache"];
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         $hash = "";
195 195
         $action = Security::getInstance()->getSessionKey("__CACHE__");
196 196
         if (null !== $action && $action["cache"] > 0) {
197
-            $hash = $action["http"] . " " . $action["slug"];
197
+            $hash = $action["http"]." ".$action["slug"];
198 198
         }
199 199
         return sha1($hash);
200 200
     }
Please login to merge, or discard this patch.