Passed
Push — Auth ( e2a482...c6ffd2 )
by Stone
01:54
created
App/Controllers/Ajax/ImageUpload.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
     private function getFilename(string $folder, string $file): string
45 45
     {
46 46
         //slugify the file name to avoid security errors or bugs with special characters.
47
-        $fileName = pathinfo($file, PATHINFO_FILENAME );
48
-        $fileExtension = pathinfo($file, PATHINFO_EXTENSION );
47
+        $fileName = pathinfo($file, PATHINFO_FILENAME);
48
+        $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
49 49
         $slugify = new Slugify();
50 50
         $fileName = $slugify->slugify($fileName);
51 51
         //if the filename has only special chars, the slugify will be empty, create a unique ID
52
-        if($fileName ==="")
52
+        if ($fileName === "")
53 53
         {
54 54
             $fileName = uniqid();
55 55
         }
56 56
         $file = $fileName.".".$fileExtension;
57
-        $fileUrl = $folder . $file;
57
+        $fileUrl = $folder.$file;
58 58
         $docRoot = $this->request->getDocumentRoot();
59
-        $filePath = $docRoot . "/public/" . $fileUrl;
59
+        $filePath = $docRoot."/public/".$fileUrl;
60 60
         if (file_exists($filePath) !== 1) {
61 61
             $fileNum = 0;
62 62
             while (file_exists($filePath)) {
63
-                $fileUrl = $folder . $fileNum . "_" . $file;
64
-                $filePath = $docRoot . "/public/" . $fileUrl;
63
+                $fileUrl = $folder.$fileNum."_".$file;
64
+                $filePath = $docRoot."/public/".$fileUrl;
65 65
                 $fileNum += 1;
66 66
             }
67 67
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
             // Respond to the successful upload with JSON.
87 87
             echo json_encode(array('location' => $filetowrite));
88
-        } else {
88
+        }else {
89 89
             // Notify editor that the upload failed
90 90
             echo json_encode(array('error' => 'Upload failed, file might be too big'));
91 91
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
             // Respond to the successful upload with JSON.
121 121
             echo json_encode(array('location' => $filetowrite));
122
-        } else {
122
+        }else {
123 123
             // Notify editor that the upload failed
124 124
             header("HTTP/1.1 500 Server Error");
125 125
         }
Please login to merge, or discard this patch.