@@ -107,7 +107,7 @@ |
||
| 107 | 107 | |
| 108 | 108 | foreach (config('chunky.validation') as $input => $config) { |
| 109 | 109 | if ( |
| 110 | - ! in_array($input, ['index', 'file', 'chunkSize', 'totalSize']) |
|
| 110 | + !in_array($input, ['index', 'file', 'chunkSize', 'totalSize']) |
|
| 111 | 111 | && Arr::has($config, 'key') |
| 112 | 112 | && Arr::has($config, 'rules') |
| 113 | 113 | ) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | public function addChunk(UploadedFile $file, int $index, string $folder): Chunk |
| 180 | 180 | { |
| 181 | 181 | // Check integrity |
| 182 | - if (! $this->checkChunks($folder, $index)) { |
|
| 182 | + if (!$this->checkChunks($folder, $index)) { |
|
| 183 | 183 | throw new ChunksIntegrityException("Uploaded chunk with index {$index} violates the integrity"); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | $default = $this->settings->defaultIndex(); |
| 216 | 216 | |
| 217 | - if (! $this->chunksFilesystem()->exists($folder) && $index != $default) { |
|
| 217 | + if (!$this->chunksFilesystem()->exists($folder) && $index != $default) { |
|
| 218 | 218 | return false; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ($index == $default) { |
| 230 | - if (! $this->chunksFilesystem()->makeDirectory($folder)) { |
|
| 230 | + if (!$this->chunksFilesystem()->makeDirectory($folder)) { |
|
| 231 | 231 | throw new ChunksIntegrityException("Cannot create chunks folder $folder"); |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | foreach ($chunks as $chunk) { |
| 247 | 247 | $size = $this->chunksFilesystem()->chunkSize($chunk->getPath()); |
| 248 | 248 | |
| 249 | - if ($size < $chunk_size && ! $chunk->isLast()) { |
|
| 249 | + if ($size < $chunk_size && !$chunk->isLast()) { |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | protected function path(string $path): string |
| 36 | 36 | { |
| 37 | - if (! Str::startsWith($path, $this->folder)) { |
|
| 37 | + if (!Str::startsWith($path, $this->folder)) { |
|
| 38 | 38 | return $this->folder().$path; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function disk($disk = null): ?string |
| 61 | 61 | { |
| 62 | - if (! empty($disk) && is_string($disk)) { |
|
| 62 | + if (!empty($disk) && is_string($disk)) { |
|
| 63 | 63 | $this->disk = $disk; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function folder($folder = null): ?string |
| 76 | 76 | { |
| 77 | - if (! empty($folder) && is_string($folder)) { |
|
| 77 | + if (!empty($folder) && is_string($folder)) { |
|
| 78 | 78 | $suffix = Str::endsWith($folder, DIRECTORY_SEPARATOR) ? '' : DIRECTORY_SEPARATOR; |
| 79 | 79 | |
| 80 | 80 | $this->folder = $folder.$suffix; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | public function __call($method, $parameters) |
| 164 | 164 | { |
| 165 | - if (! method_exists($this, $method)) { |
|
| 165 | + if (!method_exists($this, $method)) { |
|
| 166 | 166 | return $this->forwardCallTo($this->filesystem(), $method, $parameters); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | public function handle() |
| 50 | 50 | { |
| 51 | - if (! Chunky::checkChunksIntegrity($this->chunks_folder, $this->chunk_size, $this->total_size)) { |
|
| 51 | + if (!Chunky::checkChunksIntegrity($this->chunks_folder, $this->chunk_size, $this->total_size)) { |
|
| 52 | 52 | throw new ChunksIntegrityException('Chunks total file size doesnt match with original file size'); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | return ''; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if (! Str::endsWith($folder, '/')) { |
|
| 62 | + if (!Str::endsWith($folder, '/')) { |
|
| 63 | 63 | $folder .= DIRECTORY_SEPARATOR; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | return ''; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (! Str::endsWith($folder, '/')) { |
|
| 92 | + if (!Str::endsWith($folder, '/')) { |
|
| 93 | 93 | $folder .= DIRECTORY_SEPARATOR; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if ($this->handler === null) { |
| 148 | 148 | $handler = Arr::get($this->config, 'merge.handler'); |
| 149 | 149 | |
| 150 | - if (! class_exists($handler)) { |
|
| 150 | + if (!class_exists($handler)) { |
|
| 151 | 151 | throw new ChunkyException("Undefined handler $handler"); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->manager = $manager; |
| 53 | 53 | |
| 54 | - if (! $this->confirmToProceed()) { |
|
| 54 | + if (!$this->confirmToProceed()) { |
|
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $root = $this->manager->chunksFolder(); |
| 59 | 59 | $folder = $this->argument('folder'); |
| 60 | 60 | |
| 61 | - if (! empty($folder)) { |
|
| 61 | + if (!empty($folder)) { |
|
| 62 | 62 | $root .= $folder; |
| 63 | 63 | $this->deleteFolder($root); |
| 64 | 64 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | private function deleteFolder(string $folder) |
| 85 | 85 | { |
| 86 | - if (! $this->manager->deleteChunks($folder)) { |
|
| 86 | + if (!$this->manager->deleteChunks($folder)) { |
|
| 87 | 87 | $this->error("An error occurred while deleting folder {$folder}"); |
| 88 | 88 | |
| 89 | 89 | return; |
@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | private function concatenate(string $folder, string $target): string |
| 53 | 53 | { |
| 54 | - if (! $this->chunksFilesystem()->isLocal()) { |
|
| 54 | + if (!$this->chunksFilesystem()->isLocal()) { |
|
| 55 | 55 | return $this->temporaryConcatenate($target, $this->listChunks($folder)); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $chunks = $this->listChunks($folder)->map(function (Chunk $item) { |
|
| 58 | + $chunks = $this->listChunks($folder)->map(function(Chunk $item) { |
|
| 59 | 59 | return $item->getPath(); |
| 60 | 60 | }); |
| 61 | 61 | $merge = $chunks->first(); |
| 62 | 62 | |
| 63 | - if (! $this->chunksFilesystem()->concatenate($merge, $chunks->toArray())) { |
|
| 63 | + if (!$this->chunksFilesystem()->concatenate($merge, $chunks->toArray())) { |
|
| 64 | 64 | throw new ChunkyException('Unable to concatenate chunks'); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | private function temporaryConcatenate(string $target, Collection $chunks) |
| 83 | 83 | { |
| 84 | 84 | $stream = new AppendStream; |
| 85 | - $chunks->each(function (Chunk $chunk) use ($stream) { |
|
| 85 | + $chunks->each(function(Chunk $chunk) use ($stream) { |
|
| 86 | 86 | $path = $this->temp_filesystem->store('tmp-'.$chunk->getFilename(), $this->chunksFilesystem()->readChunk($chunk->getPath())); |
| 87 | 87 | $stream->append($this->temp_filesystem->readFile($path)); |
| 88 | 88 | }); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $total_size = $request->totalSizeInput(); |
| 132 | 132 | |
| 133 | 133 | if (empty($connection = $this->settings()->connection())) { |
| 134 | - if (! $this->checkChunksIntegrity($folder, $chunk_size, $total_size)) { |
|
| 134 | + if (!$this->checkChunksIntegrity($folder, $chunk_size, $total_size)) { |
|
| 135 | 135 | throw new ChunksIntegrityException('Chunks total file size doesnt match with original file size'); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | public function merge(string $chunks_folder, string $merge_path): string |
| 154 | 154 | { |
| 155 | 155 | // Check chunks folder |
| 156 | - if (! $this->isValidChunksFolder($chunks_folder)) { |
|
| 156 | + if (!$this->isValidChunksFolder($chunks_folder)) { |
|
| 157 | 157 | throw new ChunkyException("Invalid chunks folder {$chunks_folder}"); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $path = $this->concatenate($chunks_folder, $merge_path); |
| 162 | 162 | |
| 163 | 163 | // Final check and cleanup |
| 164 | - if (! $path) { |
|
| 164 | + if (!$path) { |
|
| 165 | 165 | throw new ChunkyException('An error occurred while moving merge to destination'); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | public function __call($method, $parameters) |
| 184 | 184 | { |
| 185 | - if (! method_exists($this, $method)) { |
|
| 185 | + if (!method_exists($this, $method)) { |
|
| 186 | 186 | return $this->forwardCallTo($this->manager(), $method, $parameters); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | private function registerBindings() |
| 66 | 66 | { |
| 67 | - $this->app->singleton(TempFilesystem::class, function () { |
|
| 67 | + $this->app->singleton(TempFilesystem::class, function() { |
|
| 68 | 68 | $config = $this->app->make('config'); |
| 69 | 69 | $filesystem = new TempFilesystem(app()->make(Factory::class)); |
| 70 | 70 | |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | $this->app->bind(ChunksFilesystem::class, ChunksFilesystem::class); |
| 78 | 78 | $this->app->bind(MergeFilesystem::class, MergeFilesystem::class); |
| 79 | 79 | |
| 80 | - $this->app->singleton(ChunkySettings::class, function (Container $app) { |
|
| 80 | + $this->app->singleton(ChunkySettings::class, function(Container $app) { |
|
| 81 | 81 | return new ChunkySettings($app->make('config')); |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | - $this->app->singleton(ChunkyManagerContract::class, function (Container $app) { |
|
| 84 | + $this->app->singleton(ChunkyManagerContract::class, function(Container $app) { |
|
| 85 | 85 | return new ChunkyManager($app->make(ChunkySettings::class)); |
| 86 | 86 | }); |
| 87 | 87 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $files = $this->list($folder); |
| 26 | 26 | |
| 27 | 27 | return collect($files) |
| 28 | - ->map(function ($path) use ($folder, $files) { |
|
| 28 | + ->map(function($path) use ($folder, $files) { |
|
| 29 | 29 | $filename = str_replace($folder.DIRECTORY_SEPARATOR, '', $path); |
| 30 | 30 | $exploded_name = explode('_', $filename); |
| 31 | 31 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $last = count($files) - 1 == $index; |
| 34 | 34 | |
| 35 | 35 | return new Chunk(intval($index), $path, $this->disk(), $last); |
| 36 | - })->sortBy(function (Chunk $chunk) { |
|
| 36 | + })->sortBy(function(Chunk $chunk) { |
|
| 37 | 37 | return $chunk->getIndex(); |
| 38 | 38 | })->values(); |
| 39 | 39 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function store(Chunk $chunk, string $folder, $options = []): Chunk |
| 89 | 89 | { |
| 90 | - if (! $chunk->getOriginalPath() instanceof File) { |
|
| 90 | + if (!$chunk->getOriginalPath() instanceof File) { |
|
| 91 | 91 | throw new ChunkyException('Path must be a file'); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function deleteChunk(Chunk $chunk): bool |
| 119 | 119 | { |
| 120 | - if (! $this->filesystem()->disk($this->disk())->exists($chunk->getPath())) { |
|
| 120 | + if (!$this->filesystem()->disk($this->disk())->exists($chunk->getPath())) { |
|
| 121 | 121 | return true; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | $folder = $this->path($folder); |
| 143 | 143 | |
| 144 | - if (! $this->filesystem()->disk($this->disk())->exists($folder)) { |
|
| 144 | + if (!$this->filesystem()->disk($this->disk())->exists($folder)) { |
|
| 145 | 145 | return true; |
| 146 | 146 | } |
| 147 | 147 | |