Passed
Push — develop-v4 ( d51336...06f6ef )
by Andrew
04:50
created
src/variables/TranscoderVariable.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string|false|null URL or path of the video thumbnail
55 55
      * @throws InvalidConfigException
56 56
      */
57
-    public function getVideoThumbnailUrl($filePath, $thumbnailOptions): string|false|null
57
+    public function getVideoThumbnailUrl($filePath, $thumbnailOptions): string | false | null
58 58
     {
59 59
         return Transcoder::$plugin->transcode->getVideoThumbnailUrl($filePath, $thumbnailOptions);
60 60
     }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $result = '';
170 170
         $filePath = parse_url($url, PHP_URL_PATH);
171
-        $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
171
+        $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath;
172 172
         if (file_exists($filePath)) {
173 173
             $urlParams = [
174 174
                 'url' => $url,
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      * @return string|false|null
189 189
      * @throws InvalidConfigException
190 190
      */
191
-    public function getGifUrl($filePath, $gifOptions): string|false|null
191
+    public function getGifUrl($filePath, $gifOptions): string | false | null
192 192
     {
193 193
         return Transcoder::$plugin->transcode->getGifUrl($filePath, $gifOptions);
194 194
     }
Please login to merge, or discard this patch.
src/controllers/DefaultController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *         The actions must be in 'kebab-case'
38 38
      * @access protected
39 39
      */
40
-    protected array|bool|int $allowAnonymous = [
40
+    protected array | bool | int $allowAnonymous = [
41 41
         'download-file',
42 42
         'progress',
43 43
     ];
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $filePath = parse_url($url, PHP_URL_PATH);
73 73
         // Remove any relative paths
74 74
         if (!PathHelper::ensurePathIsContained($filePath)) {
75
-            throw new BadRequestHttpException('Invalid resource path: ' . $filePath);
75
+            throw new BadRequestHttpException('Invalid resource path: '.$filePath);
76 76
         }
77 77
         // Only work for `allowedFileExtensions` file extensions
78 78
         $extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             throw new AssetDisallowedExtensionException("File “{$filePath}” cannot be downloaded because “{$extension}” is not allowed.");
82 82
         }
83 83
 
84
-        $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
84
+        $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath;
85 85
         Craft::$app->getResponse()->sendFile(
86 86
             $filePath,
87 87
             null,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public function actionProgress($filename): Response
106 106
     {
107 107
         $result = [];
108
-        $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . '.progress';
108
+        $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename.'.progress';
109 109
         if (file_exists($progressFile)) {
110 110
             $content = @file_get_contents($progressFile);
111 111
             if ($content) {
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 
117 117
                     // rawDuration is in 00:00:00.00 format. This converts it to seconds.
118 118
                     $ar = array_reverse(explode(':', $rawDuration));
119
-                    $duration = (float)$ar[0];
119
+                    $duration = (float) $ar[0];
120 120
                     if (!empty($ar[1])) {
121
-                        $duration += (int)$ar[1] * 60;
121
+                        $duration += (int) $ar[1] * 60;
122 122
                     }
123 123
                     if (!empty($ar[2])) {
124
-                        $duration += (int)$ar[2] * 60 * 60;
124
+                        $duration += (int) $ar[2] * 60 * 60;
125 125
                     }
126 126
                 } else {
127 127
                     $duration = 'unknown'; // with GIF as input, duration is unknown
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 
139 139
                 //rawTime is in 00:00:00.00 format. This converts it to seconds.
140 140
                 $ar = array_reverse(explode(':', $rawTime));
141
-                $time = (float)$ar[0];
141
+                $time = (float) $ar[0];
142 142
                 if (!empty($ar[1])) {
143
-                    $time += (int)$ar[1] * 60;
143
+                    $time += (int) $ar[1] * 60;
144 144
                 }
145 145
                 if (!empty($ar[2])) {
146
-                    $time += (int)$ar[2] * 60 * 60;
146
+                    $time += (int) $ar[2] * 60 * 60;
147 147
                 }
148 148
 
149 149
                 //calculate the progress
Please login to merge, or discard this patch.
ecs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 
6 6
 return static function(ECSConfig $ecsConfig): void {
7 7
     $ecsConfig->paths([
8
-        __DIR__ . '/src',
8
+        __DIR__.'/src',
9 9
         __FILE__,
10 10
     ]);
11 11
     $ecsConfig->parallel();
Please login to merge, or discard this patch.
src/services/Transcode.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @return string       URL of the transcoded video or ""
99 99
      * @throws InvalidConfigException
100 100
      */
101
-    public function getVideoUrl(string|Asset $filePath, array $videoOptions, bool $generate = true): string
101
+    public function getVideoUrl(string | Asset $filePath, array $videoOptions, bool $generate = true): string
102 102
     {
103 103
         $result = '';
104 104
         $settings = Transcoder::$plugin->getSettings();
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $filePath = $this->getAssetPath($filePath);
114 114
 
115 115
         if (!empty($filePath)) {
116
-            $destVideoPath = $settings['transcoderPaths']['video'] . $subfolder ?? $settings['transcoderPaths']['default'];
116
+            $destVideoPath = $settings['transcoderPaths']['video'].$subfolder ?? $settings['transcoderPaths']['default'];
117 117
             $destVideoPath = App::parseEnv($destVideoPath);
118 118
             $videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
119 119
 
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
 
126 126
             // Build the basic command for ffmpeg
127 127
             $ffmpegCmd = $settings['ffmpegPath']
128
-                . ' -i ' . escapeshellarg($filePath)
129
-                . ' -vcodec ' . $thisEncoder['videoCodec']
130
-                . ' ' . $thisEncoder['videoCodecOptions']
128
+                . ' -i '.escapeshellarg($filePath)
129
+                . ' -vcodec '.$thisEncoder['videoCodec']
130
+                . ' '.$thisEncoder['videoCodecOptions']
131 131
                 . ' -bufsize 1000k'
132
-                . ' -threads ' . $thisEncoder['threads'];
132
+                . ' -threads '.$thisEncoder['threads'];
133 133
 
134 134
             // Set the framerate if desired
135 135
             if (!empty($videoOptions['videoFrameRate'])) {
136
-                $ffmpegCmd .= ' -r ' . $videoOptions['videoFrameRate'];
136
+                $ffmpegCmd .= ' -r '.$videoOptions['videoFrameRate'];
137 137
             }
138 138
 
139 139
             // Set the bitrate if desired
140 140
             if (!empty($videoOptions['videoBitRate'])) {
141
-                $ffmpegCmd .= ' -b:v ' . $videoOptions['videoBitRate'] . ' -maxrate ' . $videoOptions['videoBitRate'];
141
+                $ffmpegCmd .= ' -b:v '.$videoOptions['videoBitRate'].' -maxrate '.$videoOptions['videoBitRate'];
142 142
             }
143 143
 
144 144
             // Adjust the scaling if desired
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
                 $ffmpegCmd .= ' -c:a copy';
157 157
             } else {
158 158
                 // Do audio transcoding based on the settings
159
-                $ffmpegCmd .= ' -acodec ' . $thisEncoder['audioCodec'];
159
+                $ffmpegCmd .= ' -acodec '.$thisEncoder['audioCodec'];
160 160
                 if (!empty($videoOptions['audioBitRate'])) {
161
-                    $ffmpegCmd .= ' -b:a ' . $videoOptions['audioBitRate'];
161
+                    $ffmpegCmd .= ' -b:a '.$videoOptions['audioBitRate'];
162 162
                 }
163 163
                 if (!empty($videoOptions['audioSampleRate'])) {
164
-                    $ffmpegCmd .= ' -ar ' . $videoOptions['audioSampleRate'];
164
+                    $ffmpegCmd .= ' -ar '.$videoOptions['audioSampleRate'];
165 165
                 }
166 166
                 if (!empty($videoOptions['audioChannels'])) {
167
-                    $ffmpegCmd .= ' -ac ' . $videoOptions['audioChannels'];
167
+                    $ffmpegCmd .= ' -ac '.$videoOptions['audioChannels'];
168 168
                 }
169
-                $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
169
+                $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions'];
170 170
             }
171 171
 
172 172
             // Create the directory if it isn't there already
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
             $destVideoFile = $this->getFilename($filePath, $videoOptions);
182 182
 
183 183
             // File to store the video encoding progress in
184
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress';
184
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress';
185 185
 
186 186
             // Assemble the destination path and final ffmpeg command
187 187
             $destVideoPath .= $destVideoFile;
188 188
             $ffmpegCmd .= ' -f '
189 189
                 . $thisEncoder['fileFormat']
190
-                . ' -y ' . escapeshellarg($destVideoPath)
191
-                . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
190
+                . ' -y '.escapeshellarg($destVideoPath)
191
+                . ' 1> '.$progressFile.' 2>&1 & echo $!';
192 192
 
193 193
             // Make sure there isn't a lockfile for this video already
194
-            $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock';
194
+            $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
195 195
             $oldPid = @file_get_contents($lockFile);
196 196
             if ($oldPid !== false) {
197 197
                 // See if the process is running, and empty result means the process is still running
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 
208 208
             // If the video file already exists and hasn't been modified, return it.  Otherwise, start it transcoding
209 209
             if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
210
-                $url = $settings['transcoderUrls']['video'] . $subfolder ?? $settings['transcoderUrls']['default'];
211
-                $result = App::parseEnv($url) . $destVideoFile;
210
+                $url = $settings['transcoderUrls']['video'].$subfolder ?? $settings['transcoderUrls']['default'];
211
+                $result = App::parseEnv($url).$destVideoFile;
212 212
             // skip encoding
213 213
             } elseif (!$generate) {
214 214
                 $result = '';
215 215
             } else {
216 216
                 // Kick off the transcoding
217 217
                 $pid = $this->executeShellCommand($ffmpegCmd);
218
-                Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
218
+                Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
219 219
 
220 220
                 // Create a lockfile in tmp
221 221
                 file_put_contents($lockFile, $pid);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      * @return string|false|null URL or path of the video thumbnail
238 238
      * @throws InvalidConfigException
239 239
      */
240
-    public function getVideoThumbnailUrl(Asset|string $filePath, array $thumbnailOptions, bool $generate = true, bool $asPath = false): string|false|null
240
+    public function getVideoThumbnailUrl(Asset | string $filePath, array $thumbnailOptions, bool $generate = true, bool $asPath = false): string | false | null
241 241
     {
242 242
         $result = null;
243 243
         $settings = Transcoder::$plugin->getSettings();
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
         $filePath = $this->getAssetPath($filePath);
252 252
 
253 253
         if (!empty($filePath)) {
254
-            $destThumbnailPath = $settings['transcoderPaths']['thumbnail'] . $subfolder ?? $settings['transcoderPaths']['default'];
254
+            $destThumbnailPath = $settings['transcoderPaths']['thumbnail'].$subfolder ?? $settings['transcoderPaths']['default'];
255 255
             $destThumbnailPath = App::parseEnv($destThumbnailPath);
256 256
 
257 257
             $thumbnailOptions = $this->coalesceOptions('defaultThumbnailOptions', $thumbnailOptions);
258 258
 
259 259
             // Build the basic command for ffmpeg
260 260
             $ffmpegCmd = $settings['ffmpegPath']
261
-                . ' -i ' . escapeshellarg($filePath)
261
+                . ' -i '.escapeshellarg($filePath)
262 262
                 . ' -vcodec mjpeg'
263 263
                 . ' -vframes 1';
264 264
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             // Set the timecode to get the thumbnail from if desired
272 272
             if (!empty($thumbnailOptions['timeInSecs'])) {
273 273
                 $timeCode = gmdate('H:i:s', $thumbnailOptions['timeInSecs']);
274
-                $ffmpegCmd .= ' -ss ' . $timeCode . '.00';
274
+                $ffmpegCmd .= ' -ss '.$timeCode.'.00';
275 275
             }
276 276
 
277 277
             // Create the directory if it isn't there already
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
             // Assemble the destination path and final ffmpeg command
289 289
             $destThumbnailPath .= $destThumbnailFile;
290
-            $ffmpegCmd .= ' -f image2 -y ' . escapeshellarg($destThumbnailPath) . ' >/dev/null 2>/dev/null &';
290
+            $ffmpegCmd .= ' -f image2 -y '.escapeshellarg($destThumbnailPath).' >/dev/null 2>/dev/null &';
291 291
 
292 292
             // If the thumbnail file already exists, return it.  Otherwise, generate it and return it
293 293
             if (!file_exists($destThumbnailPath)) {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 // if ffmpeg fails which we can't check because the process is ran in the background
300 300
                     // don't return the future path of the image or else we can't check this in the front end
301 301
                 } else {
302
-                    Craft::info('Thumbnail does not exist, but not asked to generate it: ' . $filePath, __METHOD__);
302
+                    Craft::info('Thumbnail does not exist, but not asked to generate it: '.$filePath, __METHOD__);
303 303
 
304 304
                     // The file doesn't exist, and we weren't asked to generate it
305 305
                 }
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
             if ($asPath) {
310 310
                 $result = $destThumbnailPath;
311 311
             } else {
312
-                $url = $settings['transcoderUrls']['thumbnail'] . $subfolder ?? $settings['transcoderUrls']['default'];
313
-                $result = App::parseEnv($url) . $destThumbnailFile;
312
+                $url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default'];
313
+                $result = App::parseEnv($url).$destThumbnailFile;
314 314
             }
315 315
         }
316 316
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      * @return string       URL of the transcoded audio file or ""
328 328
      * @throws InvalidConfigException
329 329
      */
330
-    public function getAudioUrl(Asset|string $filePath, array $audioOptions): string
330
+    public function getAudioUrl(Asset | string $filePath, array $audioOptions): string
331 331
     {
332 332
         $result = '';
333 333
         $settings = Transcoder::$plugin->getSettings();
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         $filePath = $this->getAssetPath($filePath);
342 342
 
343 343
         if (!empty($filePath)) {
344
-            $destAudioPath = $settings['transcoderPaths']['audio'] . $subfolder ?? $settings['transcoderPaths']['default'];
344
+            $destAudioPath = $settings['transcoderPaths']['audio'].$subfolder ?? $settings['transcoderPaths']['default'];
345 345
             $destAudioPath = App::parseEnv($destAudioPath);
346 346
 
347 347
             $audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
@@ -354,33 +354,33 @@  discard block
 block discarded – undo
354 354
 
355 355
             // Build the basic command for ffmpeg
356 356
             $ffmpegCmd = $settings['ffmpegPath']
357
-                . ' -i ' . escapeshellarg($filePath)
358
-                . ' -acodec ' . $thisEncoder['audioCodec']
359
-                . ' ' . $thisEncoder['audioCodecOptions']
357
+                . ' -i '.escapeshellarg($filePath)
358
+                . ' -acodec '.$thisEncoder['audioCodec']
359
+                . ' '.$thisEncoder['audioCodecOptions']
360 360
                 . ' -bufsize 1000k'
361 361
                 . ' -vn'
362
-                . ' -threads ' . $thisEncoder['threads'];
362
+                . ' -threads '.$thisEncoder['threads'];
363 363
 
364 364
             // Set the bitrate if desired
365 365
             if (!empty($audioOptions['audioBitRate'])) {
366
-                $ffmpegCmd .= ' -b:a ' . $audioOptions['audioBitRate'];
366
+                $ffmpegCmd .= ' -b:a '.$audioOptions['audioBitRate'];
367 367
             }
368 368
             // Set the sample rate if desired
369 369
             if (!empty($audioOptions['audioSampleRate'])) {
370
-                $ffmpegCmd .= ' -ar ' . $audioOptions['audioSampleRate'];
370
+                $ffmpegCmd .= ' -ar '.$audioOptions['audioSampleRate'];
371 371
             }
372 372
             // Set the audio channels if desired
373 373
             if (!empty($audioOptions['audioChannels'])) {
374
-                $ffmpegCmd .= ' -ac ' . $audioOptions['audioChannels'];
374
+                $ffmpegCmd .= ' -ac '.$audioOptions['audioChannels'];
375 375
             }
376
-            $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
376
+            $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions'];
377 377
 
378 378
             if (!empty($audioOptions['seekInSecs'])) {
379
-                $ffmpegCmd .= ' -ss ' . $audioOptions['seekInSecs'];
379
+                $ffmpegCmd .= ' -ss '.$audioOptions['seekInSecs'];
380 380
             }
381 381
 
382 382
             if (!empty($audioOptions['timeInSecs'])) {
383
-                $ffmpegCmd .= ' -t ' . $audioOptions['timeInSecs'];
383
+                $ffmpegCmd .= ' -t '.$audioOptions['timeInSecs'];
384 384
             }
385 385
 
386 386
             // Create the directory if it isn't there already
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
             $destAudioFile = $this->getFilename($filePath, $audioOptions);
396 396
 
397 397
             // File to store the audio encoding progress in
398
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.progress';
398
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.progress';
399 399
 
400 400
             // Assemble the destination path and final ffmpeg command
401 401
             $destAudioPath .= $destAudioFile;
@@ -410,16 +410,16 @@  discard block
 block discarded – undo
410 410
             // Add the file format
411 411
             $ffmpegCmd .= ' -f '
412 412
                 . $thisEncoder['fileFormat']
413
-                . ' -y ' . escapeshellarg($destAudioPath);
413
+                . ' -y '.escapeshellarg($destAudioPath);
414 414
             // Handle the `synchronous` setting
415 415
             $synchronous = false;
416 416
             if (!empty($audioOptions['synchronous'])) {
417 417
                 $synchronous = $audioOptions['synchronous'];
418 418
             }
419 419
             if (!$synchronous) {
420
-                $ffmpegCmd .= ' 1> ' . $progressFile . ' 2>&1 & echo $!';
420
+                $ffmpegCmd .= ' 1> '.$progressFile.' 2>&1 & echo $!';
421 421
                 // Make sure there isn't a lockfile for this audio file already
422
-                $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.lock';
422
+                $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.lock';
423 423
                 $oldPid = @file_get_contents($lockFile);
424 424
                 if ($oldPid !== false) {
425 425
                     // See if the process is running, and empty result means the process is still running
@@ -436,18 +436,18 @@  discard block
 block discarded – undo
436 436
 
437 437
             // If the audio file already exists and hasn't been modified, return it.  Otherwise, start it transcoding
438 438
             if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) {
439
-                $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default'];
440
-                $result = App::parseEnv($url) . $destAudioFile;
439
+                $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default'];
440
+                $result = App::parseEnv($url).$destAudioFile;
441 441
             } else {
442 442
                 // Kick off the transcoding
443 443
                 $pid = $this->executeShellCommand($ffmpegCmd);
444 444
 
445 445
                 if ($synchronous) {
446 446
                     Craft::info($ffmpegCmd, __METHOD__);
447
-                    $url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default'];
448
-                    $result = App::parseEnv($url) . $destAudioFile;
447
+                    $url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default'];
448
+                    $result = App::parseEnv($url).$destAudioFile;
449 449
                 } else {
450
-                    Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
450
+                    Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
451 451
                     // Create a lockfile in tmp
452 452
                     file_put_contents($lockFile, $pid);
453 453
                 }
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      * @return null|array
467 467
      * @throws InvalidConfigException
468 468
      */
469
-    public function getFileInfo(Asset|string $filePath, bool $summary = false): ?array
469
+    public function getFileInfo(Asset | string $filePath, bool $summary = false): ?array
470 470
     {
471 471
         $result = null;
472 472
         $settings = Transcoder::$plugin->getSettings();
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
             // Build the basic command for ffprobe
477 477
             $ffprobeOptions = $settings['ffprobeOptions'];
478 478
             $ffprobeCmd = $settings['ffprobePath']
479
-                . ' ' . $ffprobeOptions
480
-                . ' ' . escapeshellarg($filePath);
479
+                . ' '.$ffprobeOptions
480
+                . ' '.escapeshellarg($filePath);
481 481
 
482 482
             $shellOutput = $this->executeShellCommand($ffprobeCmd);
483 483
             Craft::info($ffprobeCmd, __METHOD__);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                     && (str_contains($summaryResult['videoFrameRate'], '/'))
524 524
                 ) {
525 525
                     $parts = explode('/', $summaryResult['videoFrameRate']);
526
-                    $summaryResult['videoFrameRate'] = (float)$parts[0] / (float)$parts[1];
526
+                    $summaryResult['videoFrameRate'] = (float) $parts[0] / (float) $parts[1];
527 527
                 }
528 528
                 $result = $summaryResult;
529 529
             }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      * @return string
542 542
      * @throws InvalidConfigException
543 543
      */
544
-    public function getVideoFilename(Asset|string $filePath, array $videoOptions): string
544
+    public function getVideoFilename(Asset | string $filePath, array $videoOptions): string
545 545
     {
546 546
         $settings = Transcoder::$plugin->getSettings();
547 547
         $videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
      * @return string
565 565
      * @throws InvalidConfigException
566 566
      */
567
-    public function getAudioFilename(Asset|string $filePath, array $audioOptions): string
567
+    public function getAudioFilename(Asset | string $filePath, array $audioOptions): string
568 568
     {
569 569
         $settings = Transcoder::$plugin->getSettings();
570 570
         $audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
      * @return string
588 588
      * @throws InvalidConfigException
589 589
      */
590
-    public function getGifFilename(Asset|string $filePath, array $gifOptions): string
590
+    public function getGifFilename(Asset | string $filePath, array $gifOptions): string
591 591
     {
592 592
         $settings = Transcoder::$plugin->getSettings();
593 593
         $gifOptions = $this->coalesceOptions('defaultGifOptions', $gifOptions);
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
      * @return null|false|string
610 610
      * @throws InvalidConfigException
611 611
      */
612
-    public function handleGetAssetThumbPath(DefineAssetThumbUrlEvent $event): null|false|string
612
+    public function handleGetAssetThumbPath(DefineAssetThumbUrlEvent $event): null | false | string
613 613
     {
614 614
         $options = [
615 615
             'width' => $event->width,
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
      * @throws InvalidConfigException
632 632
      */
633 633
 
634
-    public function getGifUrl(Asset|string $filePath, array $gifOptions): string|false|null
634
+    public function getGifUrl(Asset | string $filePath, array $gifOptions): string | false | null
635 635
     {
636 636
         $result = '';
637 637
         $settings = Transcoder::$plugin->getSettings();
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 
647 647
         if (!empty($filePath)) {
648 648
             // Dest path
649
-            $destVideoPath = $settings['transcoderPaths']['gif'] . $subfolder ?? $settings['transcoderPaths']['default'];
649
+            $destVideoPath = $settings['transcoderPaths']['gif'].$subfolder ?? $settings['transcoderPaths']['default'];
650 650
             $destVideoPath = App::parseEnv($destVideoPath);
651 651
 
652 652
             // Options
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
             // Build the basic command for ffmpeg
661 661
             $ffmpegCmd = $settings['ffmpegPath']
662 662
                 . ' -f gif'
663
-                . ' -i ' . escapeshellarg($filePath)
664
-                . ' -vcodec ' . $thisEncoder['videoCodec']
665
-                . ' ' . $thisEncoder['videoCodecOptions'];
663
+                . ' -i '.escapeshellarg($filePath)
664
+                . ' -vcodec '.$thisEncoder['videoCodec']
665
+                . ' '.$thisEncoder['videoCodecOptions'];
666 666
 
667 667
 
668 668
             // Create the directory if it isn't there already
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
             $destVideoFile = $this->getFilename($filePath, $gifOptions);
678 678
 
679 679
             // File to store the video encoding progress in
680
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress';
680
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress';
681 681
 
682 682
             // Assemble the destination path and final ffmpeg command
683 683
             $destVideoPath .= $destVideoFile;
684 684
             $ffmpegCmd .= ' '
685
-                . ' -y ' . escapeshellarg($destVideoPath)
686
-                . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
685
+                . ' -y '.escapeshellarg($destVideoPath)
686
+                . ' 1> '.$progressFile.' 2>&1 & echo $!';
687 687
 
688 688
             // Make sure there isn't a lockfile for this video already
689
-            $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock';
689
+            $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
690 690
             $oldPid = @file_get_contents($lockFile);
691 691
             if ($oldPid !== false) {
692 692
                 // See if the process is running, and empty result means the process is still running
@@ -702,12 +702,12 @@  discard block
 block discarded – undo
702 702
 
703 703
             // If the video file already exists and hasn't been modified, return it.  Otherwise, start it transcoding
704 704
             if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
705
-                $url = $settings['transcoderUrls']['gif'] . $subfolder ?? $settings['transcoderUrls']['default'];
706
-                $result = App::parseEnv($url) . $destVideoFile;
705
+                $url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default'];
706
+                $result = App::parseEnv($url).$destVideoFile;
707 707
             } else {
708 708
                 // Kick off the transcoding
709 709
                 $pid = $this->executeShellCommand($ffmpegCmd);
710
-                Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
710
+                Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
711 711
 
712 712
                 // Create a lockfile in tmp
713 713
                 file_put_contents($lockFile, $pid);
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
      * @return string
727 727
      * @throws InvalidConfigException
728 728
      */
729
-    protected function getFilename(Asset|string $filePath, array $options): string
729
+    protected function getFilename(Asset | string $filePath, array $options): string
730 730
     {
731 731
         $settings = Transcoder::$plugin->getSettings();
732 732
         $filePath = $this->getAssetPath($filePath);
@@ -749,16 +749,16 @@  discard block
 block discarded – undo
749 749
                     $suffix = self::SUFFIX_MAP[$key];
750 750
                 }
751 751
                 if (is_bool($value)) {
752
-                    $value = $value ? $key : 'no' . $key;
752
+                    $value = $value ? $key : 'no'.$key;
753 753
                 }
754 754
                 if (!in_array($key, self::EXCLUDE_PARAMS, true)) {
755
-                    $fileName .= '_' . $value . $suffix;
755
+                    $fileName .= '_'.$value.$suffix;
756 756
                 }
757 757
             }
758 758
         }
759 759
         // See if we should use a hash instead
760 760
         if ($settings['useHashedNames']) {
761
-            $fileName = $pathParts['filename'] . md5($fileName);
761
+            $fileName = $pathParts['filename'].md5($fileName);
762 762
         }
763 763
         $fileName .= $options['fileSuffix'];
764 764
 
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
      * @return string
774 774
      * @throws InvalidConfigException
775 775
      */
776
-    protected function getAssetPath(Asset|string $filePath): string
776
+    protected function getAssetPath(Asset | string $filePath): string
777 777
     {
778 778
         // If we're passed an Asset, extract the path from it
779 779
         if (($filePath instanceof Asset)) {
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
                     }
800 800
                     $folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR;
801 801
 
802
-                    $filePath = $sourcePath . $folderPath . $asset->filename;
802
+                    $filePath = $sourcePath.$folderPath.$asset->filename;
803 803
                 } else {
804 804
                     // Otherwise, get a URL
805 805
                     $filePath = $asset->getUrl() ?? '';
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
             }
808 808
         }
809 809
 
810
-        $filePath = (string)App::parseEnv($filePath);
810
+        $filePath = (string) App::parseEnv($filePath);
811 811
 
812 812
         // Make sure that $filePath is either an existing file, or a valid URL
813 813
         if (!file_exists($filePath)) {
@@ -841,16 +841,16 @@  discard block
 block discarded – undo
841 841
                     case 'letterbox':
842 842
                         $letterboxColor = '';
843 843
                         if (!empty($options['letterboxColor'])) {
844
-                            $letterboxColor = ':color=' . $options['letterboxColor'];
844
+                            $letterboxColor = ':color='.$options['letterboxColor'];
845 845
                         }
846 846
                         $aspectRatio = ':force_original_aspect_ratio=decrease'
847
-                            . ',pad=' . $options['width'] . ':' . $options['height'] . ':(ow-iw)/2:(oh-ih)/2'
847
+                            . ',pad='.$options['width'].':'.$options['height'].':(ow-iw)/2:(oh-ih)/2'
848 848
                             . $letterboxColor;
849 849
                         break;
850 850
                     // Scale to the appropriate aspect ratio, cropping
851 851
                     case 'crop':
852 852
                         $aspectRatio = ':force_original_aspect_ratio=increase'
853
-                            . ',crop=' . $options['width'] . ':' . $options['height'];
853
+                            . ',crop='.$options['width'].':'.$options['height'];
854 854
                         break;
855 855
                     // No aspect ratio scaling at all
856 856
                     default:
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
                 $sharpen = ',unsharp=5:5:1.0:5:5:0.0';
865 865
             }
866 866
             $ffmpegCmd .= ' -vf "scale='
867
-                . $options['width'] . ':' . $options['height']
867
+                . $options['width'].':'.$options['height']
868 868
                 . $aspectRatio
869 869
                 . $sharpen
870 870
                 . '"';
Please login to merge, or discard this patch.