Test Failed
Pull Request — master (#24)
by Filippo
12:43
created
src/Strategies/MergeStrategy.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function destination($destination = null): string
67 67
     {
68
-        if (is_string($destination) && ! empty($destination)) {
68
+        if (is_string($destination) && !empty($destination)) {
69 69
             $this->destination = $this->mergeManager->destinationPath($destination);
70 70
         }
71 71
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         if (is_string($folder) && $this->chunksManager->validFolder($folder)) {
81 81
             $this->folder = $folder;
82
-        } elseif (empty($this->folder) || ! $this->chunksManager->validFolder($this->folder)) {
82
+        } elseif (empty($this->folder) || !$this->chunksManager->validFolder($this->folder)) {
83 83
             throw new StrategyException('Chunks folder cannot be empty');
84 84
         }
85 85
 
Please login to merge, or discard this patch.
src/Strategies/StrategyFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
     private function buildInstance(string $strategy)
32 32
     {
33
-        if (! method_exists($strategy, 'instance')) {
33
+        if (!method_exists($strategy, 'instance')) {
34 34
             throw new StrategyException('Cannot instantiate strategy instance');
35 35
         }
36 36
 
Please login to merge, or discard this patch.
src/Strategies/FlysystemStrategy.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
     protected function mergeChunks(string $destination, array $chunks): bool
13 13
     {
14
-        if (! $this->chunksManager->chunksFilesystem()->concatenate($destination, $chunks)) {
14
+        if (!$this->chunksManager->chunksFilesystem()->concatenate($destination, $chunks)) {
15 15
             throw new StrategyException('Unable to concatenate chunks');
16 16
         }
17 17
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $this->mergeManager->getMergeOptions()
43 43
         );
44 44
 
45
-        if (! $path) {
45
+        if (!$path) {
46 46
             throw new StrategyException('An error occurred while moving merge to destination');
47 47
         }
48 48
 
Please login to merge, or discard this patch.
src/ChunkyServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,18 +68,18 @@
 block discarded – undo
68 68
         $this->app->bind(ChunksFilesystem::class, ChunksFilesystem::class);
69 69
         $this->app->bind(MergeFilesystem::class, MergeFilesystem::class);
70 70
 
71
-        $this->app->singleton(ChunksManagerContract::class, function (Container $app) {
71
+        $this->app->singleton(ChunksManagerContract::class, function(Container $app) {
72 72
             return new ChunksManager(new ChunkySettings(
73 73
                 $app->make('config')
74 74
             ));
75 75
         });
76
-        $this->app->singleton(MergeManagerContract::class, function (Container $app) {
76
+        $this->app->singleton(MergeManagerContract::class, function(Container $app) {
77 77
             return new MergeManager(new ChunkySettings(
78 78
                 $app->make('config')
79 79
             ));
80 80
         });
81 81
 
82
-        $this->app->singleton(StrategyFactoryContract::class, function (Container $app) {
82
+        $this->app->singleton(StrategyFactoryContract::class, function(Container $app) {
83 83
             return new StrategyFactory(new ChunkySettings(
84 84
                 $app->make('config')
85 85
             ));
Please login to merge, or discard this patch.
src/Support/ChunksFilesystem.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     /** {@inheritdoc} */
40 40
     public function disk($disk = null): ?string
41 41
     {
42
-        if (! empty($disk) && is_string($disk)) {
42
+        if (!empty($disk) && is_string($disk)) {
43 43
             $this->disk = $disk;
44 44
         }
45 45
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     /** {@inheritdoc} */
50 50
     public function folder($folder = null): ?string
51 51
     {
52
-        if (! empty($folder) && is_string($folder)) {
52
+        if (!empty($folder) && is_string($folder)) {
53 53
             $this->folder = $folder;
54 54
         }
55 55
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
         if (Str::startsWith($folder, $this->folder)) {
69 69
             return $folder.$suffix;
70
-        } else if(!Str::endsWith($this->folder, $folder.$suffix)) {
70
+        } else if (!Str::endsWith($this->folder, $folder.$suffix)) {
71 71
             return $this->folder.$folder.$suffix;
72 72
         }
73 73
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function store(Chunk $chunk, string $folder, $options = []): Chunk
111 111
     {
112
-        if (! $chunk->getOriginalPath() instanceof File) {
112
+        if (!$chunk->getOriginalPath() instanceof File) {
113 113
             throw new ChunkyException('Path must be a file');
114 114
         }
115 115
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         $folder = $this->fullPath($folder);
146 146
 
147
-        if (! $this->filesystem()->disk($this->disk)->exists($folder)) {
147
+        if (!$this->filesystem()->disk($this->disk)->exists($folder)) {
148 148
             return true;
149 149
         }
150 150
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function deleteChunk(Chunk $chunk): bool
167 167
     {
168
-        if (! $this->filesystem()->disk($this->disk)->exists($chunk->getPath())) {
168
+        if (!$this->filesystem()->disk($this->disk)->exists($chunk->getPath())) {
169 169
             return true;
170 170
         }
171 171
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
         $files = $this->list($folder);
191 191
 
192 192
         return collect($files)
193
-            ->map(function ($path, $key) use ($folder, $files) {
193
+            ->map(function($path, $key) use ($folder, $files) {
194 194
                 $filename = str_replace($folder, '', $path);
195 195
                 $exploded_name = explode('_', $filename);
196 196
                 $index = array_shift($exploded_name);
197 197
                 $last = count($files) - 1 == $key;
198 198
 
199 199
                 return new Chunk(intval($index), $path, $this->disk, $last);
200
-            })->sortBy(function (Chunk $chunk) {
200
+            })->sortBy(function(Chunk $chunk) {
201 201
                 return $chunk->getIndex();
202 202
             });
203 203
     }
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
     {
251 251
         $this->addTemporaryContext($folder);
252 252
 
253
-        return $chunks->map(function (Chunk $chunk) use ($folder) {
253
+        return $chunks->map(function(Chunk $chunk) use ($folder) {
254 254
             $resource = $this->filesystem()->disk($this->disk)->readStream($chunk->getPath());
255 255
             $location = $this->temporaryFilesystem()->createTemporaryFile($folder);
256 256
 
257 257
             $stream = fopen($location, 'w+b');
258 258
 
259
-            if (! $stream || stream_copy_to_stream($resource, $stream) === false || ! fclose($stream)) {
259
+            if (!$stream || stream_copy_to_stream($resource, $stream) === false || !fclose($stream)) {
260 260
                 return false;
261 261
             }
262 262
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         $stream = new AppendStream;
278 278
 
279 279
         foreach ($chunks as $chunk) {
280
-            if(!$this->isLocal()) {
280
+            if (!$this->isLocal()) {
281 281
                 $temp = fopen($chunk, 'rb');
282 282
                 $stream->append($temp);
283 283
             } else {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             }
286 286
         }
287 287
 
288
-        if(!$this->isLocal()) {
288
+        if (!$this->isLocal()) {
289 289
             file_put_contents($first, $stream->getResource());
290 290
             return $this->filesystem()->disk($this->disk)->put($destination, fopen($first, 'rb'));
291 291
         }
Please login to merge, or discard this patch.
src/Support/MergeFilesystem.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     /** {@inheritdoc} */
10 10
     public function disk($disk = null): ?string
11 11
     {
12
-        if (! empty($disk) && is_string($disk)) {
12
+        if (!empty($disk) && is_string($disk)) {
13 13
             $this->disk = $disk;
14 14
         }
15 15
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /** {@inheritdoc} */
20 20
     public function folder($folder = null): ?string
21 21
     {
22
-        if (! empty($folder) && is_string($folder)) {
22
+        if (!empty($folder) && is_string($folder)) {
23 23
             $this->folder = $folder;
24 24
         }
25 25
 
Please login to merge, or discard this patch.
src/Support/FileSystem.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
      */
57 57
     public function makeDirectory(string $folder): bool
58 58
     {
59
-        if (! Str::startsWith($folder, $this->folder)) {
59
+        if (!Str::startsWith($folder, $this->folder)) {
60 60
             $folder = $this->folder.$folder;
61 61
         }
62 62
 
Please login to merge, or discard this patch.
src/ChunksManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
     public function temporaryFiles(string $folder): Collection
134 134
     {
135 135
         $chunks = $this->chunks($folder);
136
-        if (! $this->chunksFilesystem->isLocal()) {
136
+        if (!$this->chunksFilesystem->isLocal()) {
137 137
             return $this->chunksFilesystem->createTemporaryFiles($folder, $chunks);
138 138
         }
139 139
 
140
-        return $chunks->map(function (Chunk $chunk) {
140
+        return $chunks->map(function(Chunk $chunk) {
141 141
             return $chunk->getPath();
142 142
         });
143 143
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function addChunk(UploadedFile $file, int $index, string $folder): Chunk
170 170
     {
171 171
         // Check integrity
172
-        if (! $this->checkChunkIntegrity($folder, $index)) {
172
+        if (!$this->checkChunkIntegrity($folder, $index)) {
173 173
             throw new ChunksIntegrityException("Uploaded chunk with index {$index} violates the integrity");
174 174
         }
175 175
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         $progress_bar = $this->hasProgressBar($output, count($folders));
204 204
 
205 205
         foreach ($folders as $folder) {
206
-            if (! $this->deleteChunkFolder($folder)) {
206
+            if (!$this->deleteChunkFolder($folder)) {
207 207
                 return false;
208 208
             }
209 209
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function handleMerge(string $folder, string $destination, int $chunk_size, int $total_size)
251 251
     {
252
-        if (! $this->checkFilesIntegrity($folder, $chunk_size, $total_size)) {
252
+        if (!$this->checkFilesIntegrity($folder, $chunk_size, $total_size)) {
253 253
             throw new ChunksIntegrityException('Chunks total file size doesnt match with original file size');
254 254
         }
255 255
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         $path = $this->chunksFilesystem()->fullPath($folder);
277 277
         $default = $this->settings->defaultIndex();
278 278
 
279
-        if (! $this->chunksFilesystem()->exists($path) && $index != $default) {
279
+        if (!$this->chunksFilesystem()->exists($path) && $index != $default) {
280 280
             return false;
281 281
         } elseif ($this->chunksFilesystem()->exists($path)) {
282 282
             if (ChunkySettings::INDEX_ZERO != $default) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
             return $this->chunksFilesystem()->chunksCount($path) == $index;
287 287
         } elseif ($index == $default) {
288
-            if (! $this->chunksFilesystem()->makeDirectory($path)) {
288
+            if (!$this->chunksFilesystem()->makeDirectory($path)) {
289 289
                 throw new ChunksIntegrityException("Cannot create chunks folder $path");
290 290
             }
291 291
         }
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         foreach ($chunks as $chunk) {
305 305
             $size = $this->chunksFilesystem->chunkSize($chunk->getPath());
306 306
 
307
-            if ($size < $chunk_size && ! $chunk->isLast()) {
307
+            if ($size < $chunk_size && !$chunk->isLast()) {
308 308
                 return false;
309 309
             }
310 310
 
Please login to merge, or discard this patch.
src/Commands/ClearChunks.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $this->manager = $manager;
52 52
 
53
-        if (! $this->confirmToProceed()) {
53
+        if (!$this->confirmToProceed()) {
54 54
             return;
55 55
         }
56 56
 
57 57
         $root = $this->manager->getChunksFolder();
58 58
         $folder = $this->argument('folder');
59 59
 
60
-        if (! empty($folder)) {
60
+        if (!empty($folder)) {
61 61
             $root .= $folder;
62 62
 
63
-            if (! $this->manager->chunksFilesystem()->delete($root)) {
63
+            if (!$this->manager->chunksFilesystem()->delete($root)) {
64 64
                 $this->error("An error occurred while deleting folder {$root}");
65 65
 
66 66
                 return;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
             $this->info("folder {$root} cleared!");
70 70
         } else {
71
-            if (! $this->manager->deleteAllChunks($this->output)) {
71
+            if (!$this->manager->deleteAllChunks($this->output)) {
72 72
                 $this->error("An error occurred while deleting folder {$folder}");
73 73
 
74 74
                 return;
Please login to merge, or discard this patch.