Completed
Push — V6 ( 5d3acf...b4a639 )
by Georges
02:32
created
src/phpFastCache/Core/Pool/IO/IOHelperTrait.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
          * Calculate the security key
52 52
          */
53 53
         {
54
-            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : '';
54
+            $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : '';
55 55
             if (!$securityKey || $securityKey === 'auto') {
56
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
57
-                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
56
+                if (isset($_SERVER['HTTP_HOST'])) {
57
+                    $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST'])));
58 58
                 } else {
59 59
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
60 60
                 }
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
          */
74 74
         $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR;
75 75
 
76
-        if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) {
76
+        if (empty($this->config['path']) || !is_string($this->config['path'])) {
77 77
             $path = $tmp_dir;
78 78
         } else {
79
-            $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR;
79
+            $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR;
80 80
         }
81 81
 
82 82
         $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName();
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
          * return the temp dir
92 92
          */
93 93
         if ($readonly === true) {
94
-            if($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))){
94
+            if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) {
95 95
                 return $full_path_tmp;
96 96
             }
97 97
             return $full_path;
98
-        }else{
99
-            if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
98
+        } else {
99
+            if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
100 100
                 if (!@file_exists($full_path)) {
101 101
                     @mkdir($full_path, $this->getDefaultChmod(), true);
102
-                }else if (!@is_writable($full_path)) {
103
-                    if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ])
102
+                } else if (!@is_writable($full_path)) {
103
+                    if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback'])
104 104
                     {
105 105
                         /**
106 106
                          * Switch back to tmp dir
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
                     throw new phpFastCacheIOException('Path "' . $full_path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !');
123 123
                 }
124 124
 
125
-                $this->tmp[ $full_path_hash ] = $full_path;
126
-                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
125
+                $this->tmp[$full_path_hash] = $full_path;
126
+                $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false);
127 127
             }
128 128
         }
129 129
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function getDefaultChmod()
181 181
     {
182
-        if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) {
182
+        if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) {
183 183
             return 0777;
184 184
         } else {
185
-            return $this->config[ 'default_chmod' ];
185
+            return $this->config['default_chmod'];
186 186
         }
187 187
     }
188 188
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         if ($create === true) {
213 213
             if (!is_writable($path)) {
214 214
                 try {
215
-                    if(!chmod($path, 0777)){
215
+                    if (!chmod($path, 0777)) {
216 216
                         throw new phpFastCacheIOException('Chmod failed on : ' . $path);
217 217
                     }
218 218
                 } catch (phpFastCacheIOException $e) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
          */
284 284
         $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation);
285 285
 
286
-        if($secureFileManipulation){
286
+        if ($secureFileManipulation) {
287 287
             $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5(
288 288
                 str_shuffle(uniqid($this->getDriverName(), false))
289 289
                 . str_shuffle(uniqid($this->getDriverName(), false))
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
             flock($f, LOCK_UN);
296 296
             fclose($f);
297 297
 
298
-            if(!rename($tmpFilename, $file)){
298
+            if (!rename($tmpFilename, $file)) {
299 299
                 throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file));
300 300
             }
301
-        }else{
301
+        } else {
302 302
             $f = fopen($file, 'w+');
303 303
             $octetWritten = fwrite($f, $data);
304 304
             fclose($f);
Please login to merge, or discard this patch.