Completed
Push — master ( f98e2e...5506d6 )
by Eric
02:36
created
src/Files.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function write($path, $data, $mode = 'w+')
76 76
     {
77
-        if (! $fp = @fopen($path, $mode)) {
78
-            throw new FileException('Can\'t open the file for writing! ' . $path);
77
+        if (!$fp = @fopen($path, $mode)) {
78
+            throw new FileException('Can\'t open the file for writing! '.$path);
79 79
         }
80 80
         
81 81
         flock($fp, LOCK_EX);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function read($file)
97 97
     {
98
-        if (! file_exists($file)) {
98
+        if (!file_exists($file)) {
99 99
             return FALSE;
100 100
         }
101 101
         
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         // Trim the trailing slash
132 132
         $path = rtrim($path, DIRECTORY_SEPARATOR);
133 133
         
134
-        if (! $current_dir = @opendir($path)) {
134
+        if (!$current_dir = @opendir($path)) {
135 135
             return false;
136 136
         }
137 137
         
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
         $exclude[] = '..';
140 140
         
141 141
         while (false !== ($filename = @readdir($current_dir))) {
142
-            if (! in_array($filename, $exclude)) {
143
-                if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) {
142
+            if (!in_array($filename, $exclude)) {
143
+                if (is_dir($path.DIRECTORY_SEPARATOR.$filename)) {
144 144
                     if (substr($filename, 0, 1) != '.') {
145
-                        $this->deleteDir($path . DIRECTORY_SEPARATOR . $filename, $del_dir, $level + 1, $exclude);
145
+                        $this->deleteDir($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $exclude);
146 146
                     }
147 147
                 } else {
148
-                    $this->delete($path . DIRECTORY_SEPARATOR . $filename);
148
+                    $this->delete($path.DIRECTORY_SEPARATOR.$filename);
149 149
                 }
150 150
             }
151 151
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 $bB = "B";
219 219
                 break;
220 220
         }
221
-        for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i ++) {
221
+        for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i++) {
222 222
             $val /= $factor;
223 223
         }
224 224
         $p = strpos($val, ".");
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             $val = round($val, $digits - $p);
229 229
         }
230 230
         
231
-        return round($val, $digits) . " " . $symbols[$i] . $bB;
231
+        return round($val, $digits)." ".$symbols[$i].$bB;
232 232
     }
233 233
 
234 234
     /**
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
         $file_extension = strtolower(substr(strrchr($filename, "."), 1));
248 248
         
249 249
         if ($filename == "") {
250
-            throw new FileException('Download file NOT SPECIFIED! ' . $filename);
251
-        } elseif (! file_exists($filename)) {
252
-            throw new FileException('Download file NOT Found! ' . $filename);
250
+            throw new FileException('Download file NOT SPECIFIED! '.$filename);
251
+        } elseif (!file_exists($filename)) {
252
+            throw new FileException('Download file NOT Found! '.$filename);
253 253
         }
254 254
         ;
255 255
         switch ($file_extension) {
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
295 295
         header("Cache-Control: private", false);
296 296
         header("Content-Type: $ctype");
297
-        header("Content-Disposition: attachment; filename=\"" . ($force_name ? $force_name : basename($filename)) . "\";");
297
+        header("Content-Disposition: attachment; filename=\"".($force_name ? $force_name : basename($filename))."\";");
298 298
         header("Content-Transfer-Encoding: binary");
299
-        header("Content-Length: " . $filesize);
299
+        header("Content-Length: ".$filesize);
300 300
         
301 301
         if ($fd = fopen($filename, "r")) {
302
-            while (! feof($fd)) {
302
+            while (!feof($fd)) {
303 303
                 $buffer = fread($fd, 1024 * 8);
304 304
                 echo $buffer;
305 305
             }
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
             // reset the array and make sure $source_dir has a trailing slash on the initial call
327 327
             if ($recursion === false) {
328 328
                 $this->setFileData(false, true);
329
-                $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
329
+                $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
330 330
             }
331 331
             
332 332
             while (false !== ($file = readdir($fp))) {
333
-                if (@is_dir($source_dir . $file) && strncmp($file, '.', 1) !== 0) {
334
-                    $this->getFilenames($source_dir . $file . DIRECTORY_SEPARATOR, $include_path, TRUE);
333
+                if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0) {
334
+                    $this->getFilenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
335 335
                 } elseif (strncmp($file, '.', 1) !== 0) {
336
-                    $filedata = ($include_path == TRUE) ? $source_dir . DIRECTORY_SEPARATOR . $file : $file;
336
+                    $filedata = ($include_path == TRUE) ? $source_dir.DIRECTORY_SEPARATOR.$file : $file;
337 337
                     $this->setFileData($filedata);
338 338
                 }
339 339
             }
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
             
359 359
             if ($item->isDir()) {
360 360
                 
361
-                echo $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
362
-                mkdir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), '0777', true);
361
+                echo $destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName();
362
+                mkdir($destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName(), '0777', true);
363 363
             } else {
364
-                copy($item, $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
364
+                copy($item, $destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName());
365 365
             }
366 366
         }
367 367
     }
Please login to merge, or discard this patch.