@@ -118,8 +118,7 @@ |
||
| 118 | 118 | |
| 119 | 119 | if ($this->driverIsLocal) { |
| 120 | 120 | File::makeDirectory($directory); |
| 121 | - } |
|
| 122 | - else { |
|
| 121 | + } else { |
|
| 123 | 122 | @mkdir( |
| 124 | 123 | directory: $directory, |
| 125 | 124 | recursive: true |
@@ -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); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | return new AttachmentCover($this->attachment); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function meta(string $key = null): object|int|string|null |
|
| 30 | + public function meta(string $key = null): object | int | string | null |
|
| 31 | 31 | { |
| 32 | 32 | return $this->attachment->meta($key); |
| 33 | 33 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | return $this->attachment->url($style); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function download(string $style = Larupload::ORIGINAL_FOLDER): StreamedResponse|RedirectResponse|null |
|
| 45 | + public function download(string $style = Larupload::ORIGINAL_FOLDER): StreamedResponse | RedirectResponse | null |
|
| 46 | 46 | { |
| 47 | 47 | return $this->attachment->download($style); |
| 48 | 48 | } |
@@ -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 | |
@@ -32,22 +32,19 @@ |
||
| 32 | 32 | 'Width is required when you are in SCALE_HEIGHT mode' |
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | - } |
|
| 36 | - else if ($this->mode === LaruploadMediaStyle::SCALE_WIDTH) { |
|
| 35 | + } else if ($this->mode === LaruploadMediaStyle::SCALE_WIDTH) { |
|
| 37 | 36 | if ($this->height === null or $this->height === 0) { |
| 38 | 37 | throw new Exception( |
| 39 | 38 | 'Height is required when you are in SCALE_WIDTH mode' |
| 40 | 39 | ); |
| 41 | 40 | } |
| 42 | - } |
|
| 43 | - else if (in_array($this->mode, [LaruploadMediaStyle::CROP, LaruploadMediaStyle::FIT])) { |
|
| 41 | + } else if (in_array($this->mode, [LaruploadMediaStyle::CROP, LaruploadMediaStyle::FIT])) { |
|
| 44 | 42 | if (!$this->width or !$this->height) { |
| 45 | 43 | throw new Exception( |
| 46 | 44 | 'Width and Height are required when you are in CROP/FIT mode' |
| 47 | 45 | ); |
| 48 | 46 | } |
| 49 | - } |
|
| 50 | - else if ($this->mode === LaruploadMediaStyle::AUTO) { |
|
| 47 | + } else if ($this->mode === LaruploadMediaStyle::AUTO) { |
|
| 51 | 48 | if (!$this->width and !$this->height) { |
| 52 | 49 | throw new Exception( |
| 53 | 50 | 'Width and height are required when you are in auto mode' |