@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | private FFMpegMeta $meta; |
| 33 | 33 | |
| 34 | - private Video|Audio $media; |
|
| 34 | + private Video | Audio $media; |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - public function getMedia(): Video|Audio |
|
| 65 | + public function getMedia(): Video | Audio |
|
| 66 | 66 | { |
| 67 | 67 | return $this->media; |
| 68 | 68 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function capture(int|float|null $fromSeconds, ImageStyle $style, string $saveTo, bool $withDominantColor = false): ?string |
|
| 103 | + public function capture(int | float | null $fromSeconds, ImageStyle $style, string $saveTo, bool $withDominantColor = false): ?string |
|
| 104 | 104 | { |
| 105 | 105 | $dominantColor = null; |
| 106 | 106 | $saveTo = get_larupload_save_path($this->disk, $saveTo); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return $hls->export($styles, $basePath, $fileName); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function resize(VideoStyle|ImageStyle|StreamStyle $style): void |
|
| 144 | + public function resize(VideoStyle | ImageStyle | StreamStyle $style): void |
|
| 145 | 145 | { |
| 146 | 146 | $dimension = $this->dimension($style); |
| 147 | 147 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function crop(VideoStyle|ImageStyle|StreamStyle $style): void |
|
| 160 | + public function crop(VideoStyle | ImageStyle | StreamStyle $style): void |
|
| 161 | 161 | { |
| 162 | 162 | $meta = $this->getMeta(); |
| 163 | 163 | $width = $style->width ?? null; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - private function frame(int|float|null $fromSeconds, array $saveTo): void |
|
| 181 | + private function frame(int | float | null $fromSeconds, array $saveTo): void |
|
| 182 | 182 | { |
| 183 | 183 | if (is_null($fromSeconds)) { |
| 184 | 184 | $fromSeconds = $this->getMeta()->duration / 2; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $saveToPath = $saveTo['local']; |
| 188 | 188 | $commands = [ |
| 189 | - '-y', '-ss', (string)TimeCode::fromSeconds($fromSeconds), |
|
| 189 | + '-y', '-ss', (string) TimeCode::fromSeconds($fromSeconds), |
|
| 190 | 190 | '-i', $this->media->getPathfile(), |
| 191 | 191 | '-vframes', '1', |
| 192 | 192 | '-f', 'image2', |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | return Log::channel($channel ?: config('logging.default')); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - private function dimension(VideoStyle|ImageStyle|StreamStyle $style): Dimension |
|
| 238 | + private function dimension(VideoStyle | ImageStyle | StreamStyle $style): Dimension |
|
| 239 | 239 | { |
| 240 | 240 | $width = $style->width ?: (!$style->height ? self::DEFAULT_SCALE : 1); |
| 241 | 241 | $height = $style->height ?: (!$style->width ? self::DEFAULT_SCALE : 1); |
@@ -147,8 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if ($style->padding) { |
| 149 | 149 | $this->media->filters()->pad($dimension)->synchronize(); |
| 150 | - } |
|
| 151 | - else { |
|
| 150 | + } else { |
|
| 152 | 151 | $mode = $style->mode->ffmpegResizeFilter() ?? ResizeFilter::RESIZEMODE_SCALE_HEIGHT; |
| 153 | 152 | |
| 154 | 153 | $this->media->filters() |
@@ -167,8 +166,7 @@ discard block |
||
| 167 | 166 | |
| 168 | 167 | if ($width and $height) { |
| 169 | 168 | $this->media->filters()->custom("scale=$scaleType,crop=$width:$height,setsar=1"); |
| 170 | - } |
|
| 171 | - else { |
|
| 169 | + } else { |
|
| 172 | 170 | /** |
| 173 | 171 | * With new validation rules in Video/Image/Stream style, this code will never happen |
| 174 | 172 | */ |
@@ -201,8 +199,7 @@ discard block |
||
| 201 | 199 | |
| 202 | 200 | try { |
| 203 | 201 | $this->media->getFFMpegDriver()->command($commands); |
| 204 | - } |
|
| 205 | - catch (ExecutionFailureException $e) { |
|
| 202 | + } catch (ExecutionFailureException $e) { |
|
| 206 | 203 | if (file_exists($saveToPath) && is_writable($saveToPath)) { |
| 207 | 204 | // @codeCoverageIgnoreStart |
| 208 | 205 | @unlink($saveToPath); |
@@ -35,17 +35,13 @@ |
||
| 35 | 35 | { |
| 36 | 36 | if (str_contains($mime, 'image/')) { |
| 37 | 37 | return LaruploadFileType::IMAGE; |
| 38 | - } |
|
| 39 | - else if (str_contains($mime, 'video/')) { |
|
| 38 | + } else if (str_contains($mime, 'video/')) { |
|
| 40 | 39 | return LaruploadFileType::VIDEO; |
| 41 | - } |
|
| 42 | - else if (str_contains($mime, 'audio/')) { |
|
| 40 | + } else if (str_contains($mime, 'audio/')) { |
|
| 43 | 41 | return LaruploadFileType::AUDIO; |
| 44 | - } |
|
| 45 | - else if ($this->isDocument($mime)) { |
|
| 42 | + } else if ($this->isDocument($mime)) { |
|
| 46 | 43 | return LaruploadFileType::DOCUMENT; |
| 47 | - } |
|
| 48 | - else if ($this->isCompressed($mime)) { |
|
| 44 | + } else if ($this->isCompressed($mime)) { |
|
| 49 | 45 | return LaruploadFileType::COMPRESSED; |
| 50 | 46 | } |
| 51 | 47 | |
@@ -29,11 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | if ($this->shouldDeleteCover()) { |
| 31 | 31 | $output = DeleteCoverAction::make($this->data->type, $output)->run(); |
| 32 | - } |
|
| 33 | - else if ($this->shouldUploadCover()) { |
|
| 32 | + } else if ($this->shouldUploadCover()) { |
|
| 34 | 33 | $output = UploadCoverAction::make($this->cover, $this->data)->run($path); |
| 35 | - } |
|
| 36 | - else if ($this->data->generateCover) { |
|
| 34 | + } else if ($this->data->generateCover) { |
|
| 37 | 35 | $output = GenerateCoverFromFileAction::make($this->file, $this->data)->run($path); |
| 38 | 36 | } |
| 39 | 37 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | }; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - private function retrieveCurrentSecureId(): string|null |
|
| 39 | + private function retrieveCurrentSecureId(): string | null |
|
| 40 | 40 | { |
| 41 | 41 | if ($this->attachmentMode === LaruploadMode::HEAVY) { |
| 42 | 42 | return $this->model->{"{$this->attachmentName}_file_id"} ?? null; |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | // @codeCoverageIgnoreStart |
| 38 | 38 | if (ini_get('upload_tmp_dir')) { |
| 39 | 39 | $path = ini_get('upload_tmp_dir'); |
| 40 | - } |
|
| 41 | - else if (getenv('temp')) { |
|
| 40 | + } else if (getenv('temp')) { |
|
| 42 | 41 | $path = getenv('temp'); |
| 43 | 42 | } |
| 44 | 43 | // @codeCoverageIgnoreEnd |
@@ -81,8 +80,7 @@ discard block |
||
| 81 | 80 | |
| 82 | 81 | if (disk_driver_is_local($disk)) { |
| 83 | 82 | $temp = null; |
| 84 | - } |
|
| 85 | - else { |
|
| 83 | + } else { |
|
| 86 | 84 | $tempDir = larupload_temp_dir(); |
| 87 | 85 | $tempName = \Illuminate\Support\Carbon::now()->unix() . '-' . $name; |
| 88 | 86 | $temp = "$tempDir/$tempName"; |
@@ -135,8 +133,7 @@ discard block |
||
| 135 | 133 | } |
| 136 | 134 | |
| 137 | 135 | @rmdir($path); |
| 138 | - } |
|
| 139 | - else { |
|
| 136 | + } else { |
|
| 140 | 137 | $file = new \Symfony\Component\HttpFoundation\File\File($saveTo['temp']); |
| 141 | 138 | |
| 142 | 139 | \Illuminate\Support\Facades\Storage::disk($disk)->putFileAs( |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | $table->string("{$name}_file_dominant_color", 7)->nullable(); |
| 33 | 33 | $table->string("{$name}_file_format", 85)->nullable(); |
| 34 | 34 | $table->string("{$name}_file_cover", 85)->nullable(); |
| 35 | - } |
|
| 36 | - else { |
|
| 35 | + } else { |
|
| 37 | 36 | $table->{self::jsonColumnType()}("{$name}_file_meta")->nullable(); |
| 38 | 37 | } |
| 39 | 38 | } |
@@ -65,8 +64,7 @@ discard block |
||
| 65 | 64 | $table->dropIndex("{$tableName}_{$name}_file_size_index"); |
| 66 | 65 | $table->dropIndex("{$tableName}_{$name}_file_type_index"); |
| 67 | 66 | $table->dropIndex("{$tableName}_{$name}_file_duration_index"); |
| 68 | - } |
|
| 69 | - else { |
|
| 67 | + } else { |
|
| 70 | 68 | $columns[] = "{$name}_file_meta"; |
| 71 | 69 | } |
| 72 | 70 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * @param Model|string $class |
| 19 | 19 | * @param bool $standalone |
| 20 | 20 | */ |
| 21 | - protected function handleStyles(string $id, Model|string $model, bool $standalone = false): void |
|
| 21 | + protected function handleStyles(string $id, Model | string $model, bool $standalone = false): void |
|
| 22 | 22 | { |
| 23 | 23 | switch ($this->type) { |
| 24 | 24 | case LaruploadFileType::IMAGE: |
@@ -42,14 +42,12 @@ discard block |
||
| 42 | 42 | $this->initializeFFMpegQueue( |
| 43 | 43 | $model->id, $model->getMorphClass(), $standalone |
| 44 | 44 | ); |
| 45 | - } |
|
| 46 | - else { |
|
| 45 | + } else { |
|
| 47 | 46 | $this->initializeFFMpegQueue( |
| 48 | 47 | $id, $model, $standalone |
| 49 | 48 | ); |
| 50 | 49 | } |
| 51 | - } |
|
| 52 | - else { |
|
| 50 | + } else { |
|
| 53 | 51 | $this->handleVideoStyles($id); |
| 54 | 52 | } |
| 55 | 53 | |
@@ -65,14 +63,12 @@ discard block |
||
| 65 | 63 | $this->initializeFFMpegQueue( |
| 66 | 64 | $model->id, $model->getMorphClass(), $standalone |
| 67 | 65 | ); |
| 68 | - } |
|
| 69 | - else { |
|
| 66 | + } else { |
|
| 70 | 67 | $this->initializeFFMpegQueue( |
| 71 | 68 | $id, $model, $standalone |
| 72 | 69 | ); |
| 73 | 70 | } |
| 74 | - } |
|
| 75 | - else { |
|
| 71 | + } else { |
|
| 76 | 72 | $this->handleAudioStyles($id); |
| 77 | 73 | } |
| 78 | 74 | |
@@ -154,8 +150,7 @@ discard block |
||
| 154 | 150 | } |
| 155 | 151 | |
| 156 | 152 | return null; |
| 157 | - } |
|
| 158 | - else if ($name and $this->styleHasFile($style)) { |
|
| 153 | + } else if ($name and $this->styleHasFile($style)) { |
|
| 159 | 154 | |
| 160 | 155 | $name = FixExceptionNamesAction::make($name, $style, $this->getStyle($style))->run(); |
| 161 | 156 | $path = $this->getBasePath($this->id, $style); |
@@ -61,25 +61,20 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | if ($style->mode === LaruploadMediaStyle::SCALE_HEIGHT and $style->width) { |
| 63 | 63 | $this->resizeLandscape($style->width); |
| 64 | - } |
|
| 65 | - else if ($style->mode == LaruploadMediaStyle::SCALE_WIDTH and $style->height) { |
|
| 64 | + } else if ($style->mode == LaruploadMediaStyle::SCALE_WIDTH and $style->height) { |
|
| 66 | 65 | $this->resizePortrait($style->height); |
| 67 | - } |
|
| 68 | - else if ($style->mode == LaruploadMediaStyle::CROP and $style->height and $style->width) { |
|
| 66 | + } else if ($style->mode == LaruploadMediaStyle::CROP and $style->height and $style->width) { |
|
| 69 | 67 | $this->resizeCrop($style->width, $style->height); |
| 70 | - } |
|
| 71 | - else if ($style->mode == LaruploadMediaStyle::FIT and $style->height and $style->width) { |
|
| 68 | + } else if ($style->mode == LaruploadMediaStyle::FIT and $style->height and $style->width) { |
|
| 72 | 69 | $this->resizeExact($style->width, $style->height); |
| 73 | - } |
|
| 74 | - else { |
|
| 70 | + } else { |
|
| 75 | 71 | $this->resizeAuto($style->width, $style->height); |
| 76 | 72 | } |
| 77 | 73 | |
| 78 | 74 | |
| 79 | 75 | if ($this->driverIsLocal) { |
| 80 | 76 | $this->save($saveTo); |
| 81 | - } |
|
| 82 | - else { |
|
| 77 | + } else { |
|
| 83 | 78 | list($path, $name) = split_larupload_path($saveTo); |
| 84 | 79 | |
| 85 | 80 | $tempDir = larupload_temp_dir(); |
@@ -110,8 +105,7 @@ discard block |
||
| 110 | 105 | |
| 111 | 106 | if ($file instanceof UploadedFile) { |
| 112 | 107 | $path = $file->getRealPath(); |
| 113 | - } |
|
| 114 | - else if (file_exists($file)) { |
|
| 108 | + } else if (file_exists($file)) { |
|
| 115 | 109 | $path = $file; |
| 116 | 110 | } |
| 117 | 111 | |
@@ -99,7 +99,7 @@ |
||
| 99 | 99 | /** |
| 100 | 100 | * Retrieve dominant color from image file. |
| 101 | 101 | */ |
| 102 | - public function getDominantColor(UploadedFile|string|null $file = null): ?string |
|
| 102 | + public function getDominantColor(UploadedFile | string | null $file = null): ?string |
|
| 103 | 103 | { |
| 104 | 104 | if (is_null($file)) { |
| 105 | 105 | $file = $this->file; |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | isLastOne: $this->availableQueues() === 1, |
| 56 | 56 | standalone: true |
| 57 | 57 | ); |
| 58 | - } |
|
| 59 | - else { |
|
| 58 | + } else { |
|
| 60 | 59 | /** @var Model $class */ |
| 61 | 60 | $class = class_exists($this->model) ? $this->model : Relation::getMorphedModel($this->model); |
| 62 | 61 | $modelNotSaved = true; |
@@ -75,8 +74,7 @@ discard block |
||
| 75 | 74 | } |
| 76 | 75 | |
| 77 | 76 | $this->updateStatus(true, false); |
| 78 | - } |
|
| 79 | - catch (FileNotFoundException | Exception $e) { |
|
| 77 | + } catch (FileNotFoundException | Exception $e) { |
|
| 80 | 78 | $this->updateStatus(false, false, $e->getMessage()); |
| 81 | 79 | |
| 82 | 80 | throw new Exception($e->getMessage()); |