@@ -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 | } |
@@ -60,25 +60,20 @@ discard block |
||
60 | 60 | |
61 | 61 | if ($style->mode === LaruploadMediaStyle::SCALE_HEIGHT and $style->width) { |
62 | 62 | $this->resizeLandscape($style->width); |
63 | - } |
|
64 | - else if ($style->mode == LaruploadMediaStyle::SCALE_WIDTH and $style->height) { |
|
63 | + } else if ($style->mode == LaruploadMediaStyle::SCALE_WIDTH and $style->height) { |
|
65 | 64 | $this->resizePortrait($style->height); |
66 | - } |
|
67 | - else if ($style->mode == LaruploadMediaStyle::CROP and $style->height and $style->width) { |
|
65 | + } else if ($style->mode == LaruploadMediaStyle::CROP and $style->height and $style->width) { |
|
68 | 66 | $this->resizeCrop($style->width, $style->height); |
69 | - } |
|
70 | - else if ($style->mode == LaruploadMediaStyle::FIT and $style->height and $style->width) { |
|
67 | + } else if ($style->mode == LaruploadMediaStyle::FIT and $style->height and $style->width) { |
|
71 | 68 | $this->resizeExact($style->width, $style->height); |
72 | - } |
|
73 | - else { |
|
69 | + } else { |
|
74 | 70 | $this->resizeAuto($style->width, $style->height); |
75 | 71 | } |
76 | 72 | |
77 | 73 | |
78 | 74 | if ($this->driverIsLocal) { |
79 | 75 | $this->image->save($saveTo); |
80 | - } |
|
81 | - else { |
|
76 | + } else { |
|
82 | 77 | list($path, $name) = split_larupload_path($saveTo); |
83 | 78 | |
84 | 79 | $tempDir = larupload_temp_dir(); |
@@ -109,8 +104,7 @@ discard block |
||
109 | 104 | |
110 | 105 | if ($file instanceof UploadedFile) { |
111 | 106 | $path = $file->getRealPath(); |
112 | - } |
|
113 | - else if (file_exists($file)) { |
|
107 | + } else if (file_exists($file)) { |
|
114 | 108 | $path = $file; |
115 | 109 | } |
116 | 110 |
@@ -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( |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | isLastOne: $this->availableQueues() === 1, |
54 | 54 | standalone: true |
55 | 55 | ); |
56 | - } |
|
57 | - else { |
|
56 | + } else { |
|
58 | 57 | /** @var Model $class */ |
59 | 58 | $class = $this->model; |
60 | 59 | $modelNotSaved = true; |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | } |
74 | 73 | |
75 | 74 | $this->updateStatus(true, false); |
76 | - } |
|
77 | - catch (FileNotFoundException | Exception $e) { |
|
75 | + } catch (FileNotFoundException | Exception $e) { |
|
78 | 76 | $this->updateStatus(false, false, $e->getMessage()); |
79 | 77 | |
80 | 78 | throw new Exception($e->getMessage()); |