Passed
Push — main ( 74922c...7edd23 )
by ikechukwu
03:01
created
Tests/TestCase.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function setUp(): void
10 10
     {
11
-      parent::setUp();
11
+        parent::setUp();
12 12
     }
13 13
 
14 14
     protected function defineDatabaseMigrations()
Please login to merge, or discard this patch.
src/Trait/ClamAV.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
      */
50 50
     private static function socket()
51 51
     {
52
-        if(empty(config('clamavfileupload.clamd_ip')) && empty(config('clamavfileupload.clamd_ip'))) {
52
+        if (empty(config('clamavfileupload.clamd_ip')) && empty(config('clamavfileupload.clamd_ip'))) {
53 53
             // By default we just use the local socket
54 54
             $socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
55 55
 
56
-            if(socket_connect($socket, config('clamavfileupload.clamd_sock'))) {
56
+            if (socket_connect($socket, config('clamavfileupload.clamd_sock'))) {
57 57
                 self::$message = trans('clamavfileupload::clamav.socket_connected');
58 58
                 return $socket;
59 59
             }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         // Attempt to use a network based socket
63 63
         $socket = socket_create(AF_INET, SOCK_STREAM, 0);
64 64
 
65
-        if(socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) {
65
+        if (socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) {
66 66
             self::$message = trans('clamavfileupload::clamav.socket_connected');
67 67
             return $socket;
68 68
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $ping = self::send("PING");
92 92
 
93
-        if($ping == "PONG") {
93
+        if ($ping == "PONG") {
94 94
             return true;
95 95
         }
96 96
 
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public static function scan($file): bool
108 108
     {
109
-        if(!file_exists($file)) {
109
+        if (!file_exists($file)) {
110 110
             self::$message = trans('clamavfileupload::clamav.file_not_found',
111 111
                 ['name' => $file]);
112 112
             return false;
113 113
         }
114 114
 
115 115
         $scan = self::send("SCAN $file");
116
-        if($scan === false) {
116
+        if ($scan === false) {
117 117
             self::$message = trans('clamavfileupload::clamav.not_running');
118 118
             return false;
119 119
         }
120 120
 
121 121
         $scanMessage = trim(substr(strrchr($scan, ":"), 1));
122
-        if($scanMessage == 'OK') {
122
+        if ($scanMessage == 'OK') {
123 123
             self::$message = $scanMessage;
124 124
             return true;
125 125
         }
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
     public static function scanStream($file): bool
140 140
     {
141 141
         $socket = self::socket();
142
-        if(!$socket) {
142
+        if (!$socket) {
143 143
             self::$message = trans('clamavfileupload::clamav.not_running');
144 144
             return false;
145 145
         }
146 146
 
147
-        if(!file_exists($file)) {
147
+        if (!file_exists($file)) {
148 148
             self::$message = trans('clamavfileupload::clamav.file_not_found');
149 149
             return false;
150 150
         }
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
             socket_send($socket, $packet, strlen($packet), 0);
181 181
         }
182 182
 
183
-        $packet = pack("Nx",0);
183
+        $packet = pack("Nx", 0);
184 184
         socket_send($socket, $packet, strlen($packet), 0);
185 185
         socket_recv($socket, $scan, config('clamavfileupload.clamd_sock_len'), 0);
186 186
         socket_close($socket);
187 187
 
188
-        if($scan === false) {
188
+        if ($scan === false) {
189 189
             self::$message = trans('clamavfileupload::clamav.not_running');
190 190
             return false;
191 191
         }
192 192
 
193 193
         $scanMessage = trim(substr(strrchr($scan, ":"), 1));
194
-        if($scanMessage == 'OK') {
194
+        if ($scanMessage == 'OK') {
195 195
             self::$message = $scanMessage;
196 196
             return true;
197 197
         }
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public static function send($command)
211 211
     {
212
-        if(empty($command)) {
212
+        if (empty($command)) {
213 213
             return false;
214 214
         }
215 215
 
216 216
         try {
217 217
             $socket = self::socket();
218 218
 
219
-            if($socket) {
219
+            if ($socket) {
220 220
                 socket_send($socket, $command, strlen($command), 0);
221 221
                 socket_recv($socket, $return, config('clamavfileupload.clamd_sock_len'), 0);
222 222
                 socket_close($socket);
Please login to merge, or discard this patch.
src/migrations/2023_02_16_122711_create_file_uploads_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function up(): void
13 13
     {
14
-        Schema::create('file_uploads', function (Blueprint $table) {
14
+        Schema::create('file_uploads', function(Blueprint $table) {
15 15
             $table->id();
16 16
             $table->string('ref');
17 17
             $table->string('name');
Please login to merge, or discard this patch.
src/Support/BasicFileUpload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public static function fileUpload(): bool|FileUploadModel|EloquentCollection
21 21
     {
22
-        if(self::$request->file()) {
22
+        if (self::$request->file()) {
23 23
             self::storeFiles();
24 24
 
25 25
             if (is_array(self::$request->file(self::$input))) {
Please login to merge, or discard this patch.
2023_03_03_135941_add_folder_and_hashed_fields_to_file_uploads_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function up(): void
13 13
     {
14
-        Schema::table('file_uploads', function (Blueprint $table) {
14
+        Schema::table('file_uploads', function(Blueprint $table) {
15 15
             $table->string('folder')->after('url')->nullable();
16 16
             $table->tinyInteger('hashed')->after('folder')->default(0);
17 17
         });
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function down(): void
24 24
     {
25
-        Schema::table('file_uploads', function (Blueprint $table) {
25
+        Schema::table('file_uploads', function(Blueprint $table) {
26 26
             $table->dropColumn(['folder', 'hashed']);
27 27
         });
28 28
     }
Please login to merge, or discard this patch.
...03_03_145756_increase_file_name_and_url_length_in_file_uploads_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function up(): void
13 13
     {
14
-        Schema::table('file_uploads', function (Blueprint $table) {
14
+        Schema::table('file_uploads', function(Blueprint $table) {
15 15
             $table->string('file_name', 510)->change();
16 16
             $table->string('url', 765)->change();
17 17
         });
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function down(): void
24 24
     {
25
-        Schema::table('file_uploads', function (Blueprint $table) {
25
+        Schema::table('file_uploads', function(Blueprint $table) {
26 26
             $table->string('file_name', '255')->change();
27 27
             $table->string('url', '255')->change();
28 28
         });
Please login to merge, or discard this patch.
src/Support/TemporaryFileUpload.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      * @param array $files
28 28
      * @return  ?bool
29 29
      */
30
-    public static function removeFiles(array $files = []):  ?bool
30
+    public static function removeFiles(array $files = []): ?bool
31 31
     {
32 32
         foreach ($files as $file) {
33 33
             $file = str_replace(self::storageDisk()->path('tmp'), '', $file);
34
-            self::storageDisk()->delete('tmp' . $file);
34
+            self::storageDisk()->delete('tmp'.$file);
35 35
         }
36 36
 
37 37
         return true;
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
         $i = 1;
82 82
 
83 83
         foreach (self::$request->file(self::$input) as $file) {
84
-            $tmp = $fileName . "_{$i}" . self::getExtension($file);
84
+            $tmp = $fileName."_{$i}".self::getExtension($file);
85 85
             $disk->putFileAs("", $file, $tmp);
86 86
             $tmpFiles[] = self::storageDisk()->path("tmp/{$tmp}");
87 87
 
88
-            $i ++;
88
+            $i++;
89 89
         }
90 90
 
91 91
         return $tmpFiles;
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected static function saveSingleFile(?string $fileName = null): bool|array
102 102
     {
103
-        $tmp = $fileName . self::getExtension();
103
+        $tmp = $fileName.self::getExtension();
104 104
 
105 105
         self::provideDisk()->putFileAs("",
106 106
                 self::$request->file(self::$input),
107
-                $fileName . self::getExtension());
107
+                $fileName.self::getExtension());
108 108
 
109 109
         return [self::storageDisk()->path("tmp/{$tmp}")];
110 110
     }
Please login to merge, or discard this patch.
src/Foundation/FileUpload.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 
79 79
         $i = 1;
80 80
         foreach (self::$request->file(self::$input) as $file) {
81
-            $disk->putFileAs("", $file, self::$fileName . "_{$i}" .
81
+            $disk->putFileAs("", $file, self::$fileName."_{$i}".
82 82
                     self::getExtension($file));
83
-            $i ++;
83
+            $i++;
84 84
         }
85 85
 
86 86
         return true;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         self::provideDisk()->putFileAs("",
99 99
                 self::$request->file(self::$input),
100
-                self::$fileName . self::getExtension());
100
+                self::$fileName.self::getExtension());
101 101
 
102 102
         return true;
103 103
     }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 
131 131
             $file = str_replace(self::storageDisk()
132 132
                         ->path(self::$uploadPath), '', $file);
133
-            self::storageDisk()->delete(self::$uploadPath . $file);
133
+            self::storageDisk()->delete(self::$uploadPath.$file);
134 134
 
135
-            $i ++;
135
+            $i++;
136 136
         }
137 137
 
138 138
         return true;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
         $file = str_replace(self::storageDisk()
151 151
                 ->path(self::$uploadPath), '', self::$request->file(self::$input));
152
-        self::storageDisk()->delete(self::$uploadPath . $file);
152
+        self::storageDisk()->delete(self::$uploadPath.$file);
153 153
 
154 154
         return true;
155 155
     }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     protected static function getName($file = null, $i = null): string
175 175
     {
176 176
         if ($file && $i) {
177
-            return self::$name ? self::$name . "_{$i}"
177
+            return self::$name ? self::$name."_{$i}"
178 178
                 : $file->getClientOriginalName();
179 179
         }
180 180
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     protected static function setFileName(): string
191 191
     {
192
-        return time() . Str::random(40);
192
+        return time().Str::random(40);
193 193
     }
194 194
 
195 195
     /**
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
     protected static function getExtension($file = null): string
233 233
     {
234 234
         if ($file) {
235
-            return '.' . $file->getClientOriginalExtension();
235
+            return '.'.$file->getClientOriginalExtension();
236 236
         }
237 237
 
238
-        return '.' . self::$request->file(self::$input)
238
+        return '.'.self::$request->file(self::$input)
239 239
                 ->getClientOriginalExtension();
240 240
     }
241 241
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     protected static function getRelativeFilePath($fileName): string
249 249
     {
250
-        return self::$uploadPath . "/" . $fileName;
250
+        return self::$uploadPath."/".$fileName;
251 251
     }
252 252
 
253 253
     /**
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
     protected static function fileNameAndPath($file = null, $i = null): array
281 281
     {
282 282
         if ($file && $i) {
283
-            $fileName = self::$fileName . "_{$i}" . self::getExtension($file);
283
+            $fileName = self::$fileName."_{$i}".self::getExtension($file);
284 284
             return [$fileName, self::getRelativeFilePath($fileName)];
285 285
         }
286 286
 
287
-        $fileName = self::$fileName . self::getExtension();
287
+        $fileName = self::$fileName.self::getExtension();
288 288
         return [$fileName, self::getRelativeFilePath($fileName)];
289 289
     }
290 290
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
         foreach (self::$request->file(self::$input) as $file) {
327 327
             $data[] = self::getFileModelData($file, $i);
328
-            $i ++;
328
+            $i++;
329 329
         }
330 330
 
331 331
         if (FileUploadModel::insert($data)) {
Please login to merge, or discard this patch.
src/Facade/FileUploadLogic.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
         }
55 55
 
56 56
         if (self::$folder) {
57
-            self::$uploadPath .= ("/" . self::$folder);
57
+            self::$uploadPath .= ("/".self::$folder);
58 58
         }
59 59
     }
60 60
 
Please login to merge, or discard this patch.