Passed
Push — v5 ( 887df8...579485 )
by Andrew
17:51 queued 13:09
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.
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/controllers/DefaultController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     // Protected Properties
32 32
     // =========================================================================
33 33
 
34
-    protected array|bool|int $allowAnonymous = [
34
+    protected array | bool | int $allowAnonymous = [
35 35
         'download-file',
36 36
         'progress',
37 37
     ];
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $filePath = parse_url($url, PHP_URL_PATH);
67 67
         // Remove any relative paths
68 68
         if (!PathHelper::ensurePathIsContained($filePath)) {
69
-            throw new BadRequestHttpException('Invalid resource path: ' . $filePath);
69
+            throw new BadRequestHttpException('Invalid resource path: '.$filePath);
70 70
         }
71 71
         // Only work for `allowedFileExtensions` file extensions
72 72
         $extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             throw new AssetDisallowedExtensionException("File “{$filePath}” cannot be downloaded because “{$extension}” is not allowed.");
76 76
         }
77 77
 
78
-        $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
78
+        $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath;
79 79
         Craft::$app->getResponse()->sendFile(
80 80
             $filePath,
81 81
             null,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public function actionProgress($filename): Response
100 100
     {
101 101
         $result = [];
102
-        $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . '.progress';
102
+        $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename.'.progress';
103 103
         if (file_exists($progressFile)) {
104 104
             $content = @file_get_contents($progressFile);
105 105
             if ($content) {
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 
111 111
                     // rawDuration is in 00:00:00.00 format. This converts it to seconds.
112 112
                     $ar = array_reverse(explode(':', $rawDuration));
113
-                    $duration = (float)$ar[0];
113
+                    $duration = (float) $ar[0];
114 114
                     if (!empty($ar[1])) {
115
-                        $duration += (int)$ar[1] * 60;
115
+                        $duration += (int) $ar[1] * 60;
116 116
                     }
117 117
                     if (!empty($ar[2])) {
118
-                        $duration += (int)$ar[2] * 60 * 60;
118
+                        $duration += (int) $ar[2] * 60 * 60;
119 119
                     }
120 120
                 } else {
121 121
                     $duration = 'unknown'; // with GIF as input, duration is unknown
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 
133 133
                 //rawTime is in 00:00:00.00 format. This converts it to seconds.
134 134
                 $ar = array_reverse(explode(':', $rawTime));
135
-                $time = (float)$ar[0];
135
+                $time = (float) $ar[0];
136 136
                 if (!empty($ar[1])) {
137
-                    $time += (int)$ar[1] * 60;
137
+                    $time += (int) $ar[1] * 60;
138 138
                 }
139 139
                 if (!empty($ar[2])) {
140
-                    $time += (int)$ar[2] * 60 * 60;
140
+                    $time += (int) $ar[2] * 60 * 60;
141 141
                 }
142 142
 
143 143
                 //calculate the progress
Please login to merge, or discard this patch.
src/services/Transcode.php 1 patch
Spacing   +71 added lines, -71 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();
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 
127 127
             // Build the basic command for ffmpeg
128 128
             $ffmpegCmd = $settings['ffmpegPath']
129
-                . ' -i ' . escapeshellarg($filePath)
130
-                . ' -vcodec ' . $thisEncoder['videoCodec']
131
-                . ' ' . $thisEncoder['videoCodecOptions']
129
+                . ' -i '.escapeshellarg($filePath)
130
+                . ' -vcodec '.$thisEncoder['videoCodec']
131
+                . ' '.$thisEncoder['videoCodecOptions']
132 132
                 . ' -bufsize 1000k'
133
-                . ' -threads ' . $thisEncoder['threads'];
133
+                . ' -threads '.$thisEncoder['threads'];
134 134
 
135 135
             // Set the framerate if desired
136 136
             if (!empty($videoOptions['videoFrameRate'])) {
137
-                $ffmpegCmd .= ' -r ' . $videoOptions['videoFrameRate'];
137
+                $ffmpegCmd .= ' -r '.$videoOptions['videoFrameRate'];
138 138
             }
139 139
 
140 140
             // Set the bitrate if desired
141 141
             if (!empty($videoOptions['videoBitRate'])) {
142
-                $ffmpegCmd .= ' -b:v ' . $videoOptions['videoBitRate'] . ' -maxrate ' . $videoOptions['videoBitRate'];
142
+                $ffmpegCmd .= ' -b:v '.$videoOptions['videoBitRate'].' -maxrate '.$videoOptions['videoBitRate'];
143 143
             }
144 144
 
145 145
             // Adjust the scaling if desired
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
                 $ffmpegCmd .= ' -c:a copy';
158 158
             } else {
159 159
                 // Do audio transcoding based on the settings
160
-                $ffmpegCmd .= ' -acodec ' . $thisEncoder['audioCodec'];
160
+                $ffmpegCmd .= ' -acodec '.$thisEncoder['audioCodec'];
161 161
                 if (!empty($videoOptions['audioBitRate'])) {
162
-                    $ffmpegCmd .= ' -b:a ' . $videoOptions['audioBitRate'];
162
+                    $ffmpegCmd .= ' -b:a '.$videoOptions['audioBitRate'];
163 163
                 }
164 164
                 if (!empty($videoOptions['audioSampleRate'])) {
165
-                    $ffmpegCmd .= ' -ar ' . $videoOptions['audioSampleRate'];
165
+                    $ffmpegCmd .= ' -ar '.$videoOptions['audioSampleRate'];
166 166
                 }
167 167
                 if (!empty($videoOptions['audioChannels'])) {
168
-                    $ffmpegCmd .= ' -ac ' . $videoOptions['audioChannels'];
168
+                    $ffmpegCmd .= ' -ac '.$videoOptions['audioChannels'];
169 169
                 }
170
-                $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
170
+                $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions'];
171 171
             }
172 172
 
173 173
             // Create the directory if it isn't there already
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
             $destVideoFile = $this->getFilename($filePath, $videoOptions);
183 183
 
184 184
             // File to store the video encoding progress in
185
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress';
185
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress';
186 186
 
187 187
             // Assemble the destination path and final ffmpeg command
188 188
             $destVideoPath .= $destVideoFile;
189 189
             $ffmpegCmd .= ' -f '
190 190
                 . $thisEncoder['fileFormat']
191
-                . ' -y ' . escapeshellarg($destVideoPath)
192
-                . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
191
+                . ' -y '.escapeshellarg($destVideoPath)
192
+                . ' 1> '.$progressFile.' 2>&1 & echo $!';
193 193
 
194 194
             // Make sure there isn't a lockfile for this video already
195
-            $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock';
195
+            $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
196 196
             $oldPid = @file_get_contents($lockFile);
197 197
             if ($oldPid !== false) {
198 198
                 // See if the process is running, and empty result means the process is still running
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
             if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
211 211
                 $url = $settings['transcoderUrls']['video'] ?? $settings['transcoderUrls']['default'];
212 212
                 $url .= $subfolder;
213
-                $result = App::parseEnv($url) . $destVideoFile;
213
+                $result = App::parseEnv($url).$destVideoFile;
214 214
             // skip encoding
215 215
             } elseif (!$generate) {
216 216
                 $result = '';
217 217
             } else {
218 218
                 // Kick off the transcoding
219 219
                 $pid = $this->executeShellCommand($ffmpegCmd);
220
-                Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
220
+                Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
221 221
 
222 222
                 // Create a lockfile in tmp
223 223
                 file_put_contents($lockFile, $pid);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @return string|false|null URL or path of the video thumbnail
240 240
      * @throws InvalidConfigException
241 241
      */
242
-    public function getVideoThumbnailUrl(Asset|string $filePath, array $thumbnailOptions, bool $generate = true, bool $asPath = false): string|false|null
242
+    public function getVideoThumbnailUrl(Asset | string $filePath, array $thumbnailOptions, bool $generate = true, bool $asPath = false): string | false | null
243 243
     {
244 244
         $result = null;
245 245
         $settings = Transcoder::$plugin->getSettings();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
             // Build the basic command for ffmpeg
263 263
             $ffmpegCmd = $settings['ffmpegPath']
264
-                . ' -i ' . escapeshellarg($filePath)
264
+                . ' -i '.escapeshellarg($filePath)
265 265
                 . ' -vcodec mjpeg'
266 266
                 . ' -vframes 1';
267 267
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             // Set the timecode to get the thumbnail from if desired
275 275
             if (!empty($thumbnailOptions['timeInSecs'])) {
276 276
                 $timeCode = gmdate('H:i:s', $thumbnailOptions['timeInSecs']);
277
-                $ffmpegCmd .= ' -ss ' . $timeCode . '.00';
277
+                $ffmpegCmd .= ' -ss '.$timeCode.'.00';
278 278
             }
279 279
 
280 280
             // Create the directory if it isn't there already
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 
291 291
             // Assemble the destination path and final ffmpeg command
292 292
             $destThumbnailPath .= $destThumbnailFile;
293
-            $ffmpegCmd .= ' -f image2 -y ' . escapeshellarg($destThumbnailPath) . ' >/dev/null 2>/dev/null &';
293
+            $ffmpegCmd .= ' -f image2 -y '.escapeshellarg($destThumbnailPath).' >/dev/null 2>/dev/null &';
294 294
 
295 295
             // If the thumbnail file already exists, return it.  Otherwise, generate it and return it
296 296
             if (!file_exists($destThumbnailPath)) {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 // if ffmpeg fails which we can't check because the process is ran in the background
303 303
                     // don't return the future path of the image or else we can't check this in the front end
304 304
                 } else {
305
-                    Craft::info('Thumbnail does not exist, but not asked to generate it: ' . $filePath, __METHOD__);
305
+                    Craft::info('Thumbnail does not exist, but not asked to generate it: '.$filePath, __METHOD__);
306 306
 
307 307
                     // The file doesn't exist, and we weren't asked to generate it
308 308
                 }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             } else {
315 315
                 $url = $settings['transcoderUrls']['thumbnail'] ?? $settings['transcoderUrls']['default'];
316 316
                 $url .= $subfolder;
317
-                $result = App::parseEnv($url) . $destThumbnailFile;
317
+                $result = App::parseEnv($url).$destThumbnailFile;
318 318
             }
319 319
         }
320 320
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @return string       URL of the transcoded audio file or ""
332 332
      * @throws InvalidConfigException
333 333
      */
334
-    public function getAudioUrl(Asset|string $filePath, array $audioOptions): string
334
+    public function getAudioUrl(Asset | string $filePath, array $audioOptions): string
335 335
     {
336 336
         $result = '';
337 337
         $settings = Transcoder::$plugin->getSettings();
@@ -359,33 +359,33 @@  discard block
 block discarded – undo
359 359
 
360 360
             // Build the basic command for ffmpeg
361 361
             $ffmpegCmd = $settings['ffmpegPath']
362
-                . ' -i ' . escapeshellarg($filePath)
363
-                . ' -acodec ' . $thisEncoder['audioCodec']
364
-                . ' ' . $thisEncoder['audioCodecOptions']
362
+                . ' -i '.escapeshellarg($filePath)
363
+                . ' -acodec '.$thisEncoder['audioCodec']
364
+                . ' '.$thisEncoder['audioCodecOptions']
365 365
                 . ' -bufsize 1000k'
366 366
                 . ' -vn'
367
-                . ' -threads ' . $thisEncoder['threads'];
367
+                . ' -threads '.$thisEncoder['threads'];
368 368
 
369 369
             // Set the bitrate if desired
370 370
             if (!empty($audioOptions['audioBitRate'])) {
371
-                $ffmpegCmd .= ' -b:a ' . $audioOptions['audioBitRate'];
371
+                $ffmpegCmd .= ' -b:a '.$audioOptions['audioBitRate'];
372 372
             }
373 373
             // Set the sample rate if desired
374 374
             if (!empty($audioOptions['audioSampleRate'])) {
375
-                $ffmpegCmd .= ' -ar ' . $audioOptions['audioSampleRate'];
375
+                $ffmpegCmd .= ' -ar '.$audioOptions['audioSampleRate'];
376 376
             }
377 377
             // Set the audio channels if desired
378 378
             if (!empty($audioOptions['audioChannels'])) {
379
-                $ffmpegCmd .= ' -ac ' . $audioOptions['audioChannels'];
379
+                $ffmpegCmd .= ' -ac '.$audioOptions['audioChannels'];
380 380
             }
381
-            $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
381
+            $ffmpegCmd .= ' '.$thisEncoder['audioCodecOptions'];
382 382
 
383 383
             if (!empty($audioOptions['seekInSecs'])) {
384
-                $ffmpegCmd .= ' -ss ' . $audioOptions['seekInSecs'];
384
+                $ffmpegCmd .= ' -ss '.$audioOptions['seekInSecs'];
385 385
             }
386 386
 
387 387
             if (!empty($audioOptions['timeInSecs'])) {
388
-                $ffmpegCmd .= ' -t ' . $audioOptions['timeInSecs'];
388
+                $ffmpegCmd .= ' -t '.$audioOptions['timeInSecs'];
389 389
             }
390 390
 
391 391
             // Create the directory if it isn't there already
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             $destAudioFile = $this->getFilename($filePath, $audioOptions);
401 401
 
402 402
             // File to store the audio encoding progress in
403
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.progress';
403
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.progress';
404 404
 
405 405
             // Assemble the destination path and final ffmpeg command
406 406
             $destAudioPath .= $destAudioFile;
@@ -415,16 +415,16 @@  discard block
 block discarded – undo
415 415
             // Add the file format
416 416
             $ffmpegCmd .= ' -f '
417 417
                 . $thisEncoder['fileFormat']
418
-                . ' -y ' . escapeshellarg($destAudioPath);
418
+                . ' -y '.escapeshellarg($destAudioPath);
419 419
             // Handle the `synchronous` setting
420 420
             $synchronous = false;
421 421
             if (!empty($audioOptions['synchronous'])) {
422 422
                 $synchronous = $audioOptions['synchronous'];
423 423
             }
424 424
             if (!$synchronous) {
425
-                $ffmpegCmd .= ' 1> ' . $progressFile . ' 2>&1 & echo $!';
425
+                $ffmpegCmd .= ' 1> '.$progressFile.' 2>&1 & echo $!';
426 426
                 // Make sure there isn't a lockfile for this audio file already
427
-                $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destAudioFile . '.lock';
427
+                $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destAudioFile.'.lock';
428 428
                 $oldPid = @file_get_contents($lockFile);
429 429
                 if ($oldPid !== false) {
430 430
                     // See if the process is running, and empty result means the process is still running
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
             if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) {
444 444
                 $url = $settings['transcoderUrls']['audio'] ?? $settings['transcoderUrls']['default'];
445 445
                 $url .= $subfolder;
446
-                $result = App::parseEnv($url) . $destAudioFile;
446
+                $result = App::parseEnv($url).$destAudioFile;
447 447
             } else {
448 448
                 // Kick off the transcoding
449 449
                 $pid = $this->executeShellCommand($ffmpegCmd);
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
                     Craft::info($ffmpegCmd, __METHOD__);
453 453
                     $url = $settings['transcoderUrls']['audio'] ?? $settings['transcoderUrls']['default'];
454 454
                     $url .= $subfolder;
455
-                    $result = App::parseEnv($url) . $destAudioFile;
455
+                    $result = App::parseEnv($url).$destAudioFile;
456 456
                 } else {
457
-                    Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
457
+                    Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
458 458
                     // Create a lockfile in tmp
459 459
                     file_put_contents($lockFile, $pid);
460 460
                 }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      * @return null|array
474 474
      * @throws InvalidConfigException
475 475
      */
476
-    public function getFileInfo(Asset|string $filePath, bool $summary = false): ?array
476
+    public function getFileInfo(Asset | string $filePath, bool $summary = false): ?array
477 477
     {
478 478
         $result = null;
479 479
         $settings = Transcoder::$plugin->getSettings();
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
             // Build the basic command for ffprobe
484 484
             $ffprobeOptions = $settings['ffprobeOptions'];
485 485
             $ffprobeCmd = $settings['ffprobePath']
486
-                . ' ' . $ffprobeOptions
487
-                . ' ' . escapeshellarg($filePath);
486
+                . ' '.$ffprobeOptions
487
+                . ' '.escapeshellarg($filePath);
488 488
 
489 489
             $shellOutput = $this->executeShellCommand($ffprobeCmd);
490 490
             Craft::info($ffprobeCmd, __METHOD__);
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
                     && (str_contains($summaryResult['videoFrameRate'], '/'))
531 531
                 ) {
532 532
                     $parts = explode('/', $summaryResult['videoFrameRate']);
533
-                    $summaryResult['videoFrameRate'] = (float)$parts[0] / (float)$parts[1];
533
+                    $summaryResult['videoFrameRate'] = (float) $parts[0] / (float) $parts[1];
534 534
                 }
535 535
                 $result = $summaryResult;
536 536
             }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
      * @return string
549 549
      * @throws InvalidConfigException
550 550
      */
551
-    public function getVideoFilename(Asset|string $filePath, array $videoOptions): string
551
+    public function getVideoFilename(Asset | string $filePath, array $videoOptions): string
552 552
     {
553 553
         $settings = Transcoder::$plugin->getSettings();
554 554
         $videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
      * @return string
572 572
      * @throws InvalidConfigException
573 573
      */
574
-    public function getAudioFilename(Asset|string $filePath, array $audioOptions): string
574
+    public function getAudioFilename(Asset | string $filePath, array $audioOptions): string
575 575
     {
576 576
         $settings = Transcoder::$plugin->getSettings();
577 577
         $audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      * @return string
595 595
      * @throws InvalidConfigException
596 596
      */
597
-    public function getGifFilename(Asset|string $filePath, array $gifOptions): string
597
+    public function getGifFilename(Asset | string $filePath, array $gifOptions): string
598 598
     {
599 599
         $settings = Transcoder::$plugin->getSettings();
600 600
         $gifOptions = $this->coalesceOptions('defaultGifOptions', $gifOptions);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
      * @return null|false|string
617 617
      * @throws InvalidConfigException
618 618
      */
619
-    public function handleGetAssetThumbPath(DefineAssetThumbUrlEvent $event): null|false|string
619
+    public function handleGetAssetThumbPath(DefineAssetThumbUrlEvent $event): null | false | string
620 620
     {
621 621
         $options = [
622 622
             'width' => $event->width,
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
      * @throws InvalidConfigException
639 639
      */
640 640
 
641
-    public function getGifUrl(Asset|string $filePath, array $gifOptions): string|false|null
641
+    public function getGifUrl(Asset | string $filePath, array $gifOptions): string | false | null
642 642
     {
643 643
         $result = '';
644 644
         $settings = Transcoder::$plugin->getSettings();
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
             // Build the basic command for ffmpeg
669 669
             $ffmpegCmd = $settings['ffmpegPath']
670 670
                 . ' -f gif'
671
-                . ' -i ' . escapeshellarg($filePath)
672
-                . ' -vcodec ' . $thisEncoder['videoCodec']
673
-                . ' ' . $thisEncoder['videoCodecOptions'];
671
+                . ' -i '.escapeshellarg($filePath)
672
+                . ' -vcodec '.$thisEncoder['videoCodec']
673
+                . ' '.$thisEncoder['videoCodecOptions'];
674 674
 
675 675
 
676 676
             // Create the directory if it isn't there already
@@ -685,16 +685,16 @@  discard block
 block discarded – undo
685 685
             $destVideoFile = $this->getFilename($filePath, $gifOptions);
686 686
 
687 687
             // File to store the video encoding progress in
688
-            $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.progress';
688
+            $progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.progress';
689 689
 
690 690
             // Assemble the destination path and final ffmpeg command
691 691
             $destVideoPath .= $destVideoFile;
692 692
             $ffmpegCmd .= ' '
693
-                . ' -y ' . escapeshellarg($destVideoPath)
694
-                . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
693
+                . ' -y '.escapeshellarg($destVideoPath)
694
+                . ' 1> '.$progressFile.' 2>&1 & echo $!';
695 695
 
696 696
             // Make sure there isn't a lockfile for this video already
697
-            $lockFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destVideoFile . '.lock';
697
+            $lockFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$destVideoFile.'.lock';
698 698
             $oldPid = @file_get_contents($lockFile);
699 699
             if ($oldPid !== false) {
700 700
                 // See if the process is running, and empty result means the process is still running
@@ -712,11 +712,11 @@  discard block
 block discarded – undo
712 712
             if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
713 713
                 $url = $settings['transcoderUrls']['gif'] ?? $settings['transcoderUrls']['default'];
714 714
                 $url .= $subfolder;
715
-                $result = App::parseEnv($url) . $destVideoFile;
715
+                $result = App::parseEnv($url).$destVideoFile;
716 716
             } else {
717 717
                 // Kick off the transcoding
718 718
                 $pid = $this->executeShellCommand($ffmpegCmd);
719
-                Craft::info($ffmpegCmd . "\nffmpeg PID: " . $pid, __METHOD__);
719
+                Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
720 720
 
721 721
                 // Create a lockfile in tmp
722 722
                 file_put_contents($lockFile, $pid);
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      * @return string
736 736
      * @throws InvalidConfigException
737 737
      */
738
-    protected function getFilename(Asset|string $filePath, array $options): string
738
+    protected function getFilename(Asset | string $filePath, array $options): string
739 739
     {
740 740
         $settings = Transcoder::$plugin->getSettings();
741 741
         $filePath = $this->getAssetPath($filePath);
@@ -758,16 +758,16 @@  discard block
 block discarded – undo
758 758
                     $suffix = self::SUFFIX_MAP[$key];
759 759
                 }
760 760
                 if (is_bool($value)) {
761
-                    $value = $value ? $key : 'no' . $key;
761
+                    $value = $value ? $key : 'no'.$key;
762 762
                 }
763 763
                 if (!in_array($key, self::EXCLUDE_PARAMS, true)) {
764
-                    $fileName .= '_' . $value . $suffix;
764
+                    $fileName .= '_'.$value.$suffix;
765 765
                 }
766 766
             }
767 767
         }
768 768
         // See if we should use a hash instead
769 769
         if ($settings['useHashedNames']) {
770
-            $fileName = $pathParts['filename'] . md5($fileName);
770
+            $fileName = $pathParts['filename'].md5($fileName);
771 771
         }
772 772
         $fileName .= $options['fileSuffix'];
773 773
 
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
      * @return string
783 783
      * @throws InvalidConfigException
784 784
      */
785
-    protected function getAssetPath(Asset|string $filePath): string
785
+    protected function getAssetPath(Asset | string $filePath): string
786 786
     {
787 787
         // If we're passed an Asset, extract the path from it
788 788
         if (($filePath instanceof Asset)) {
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
                     }
809 809
                     $folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR;
810 810
 
811
-                    $filePath = $sourcePath . $folderPath . $asset->filename;
811
+                    $filePath = $sourcePath.$folderPath.$asset->filename;
812 812
                 } else {
813 813
                     // Otherwise, get a URL
814 814
                     $filePath = $asset->getUrl() ?? '';
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
             }
817 817
         }
818 818
 
819
-        $filePath = (string)App::parseEnv($filePath);
819
+        $filePath = (string) App::parseEnv($filePath);
820 820
 
821 821
         // Make sure that $filePath is either an existing file, or a valid URL
822 822
         if (!file_exists($filePath)) {
@@ -850,16 +850,16 @@  discard block
 block discarded – undo
850 850
                     case 'letterbox':
851 851
                         $letterboxColor = '';
852 852
                         if (!empty($options['letterboxColor'])) {
853
-                            $letterboxColor = ':color=' . $options['letterboxColor'];
853
+                            $letterboxColor = ':color='.$options['letterboxColor'];
854 854
                         }
855 855
                         $aspectRatio = ':force_original_aspect_ratio=decrease'
856
-                            . ',pad=' . $options['width'] . ':' . $options['height'] . ':(ow-iw)/2:(oh-ih)/2'
856
+                            . ',pad='.$options['width'].':'.$options['height'].':(ow-iw)/2:(oh-ih)/2'
857 857
                             . $letterboxColor;
858 858
                         break;
859 859
                     // Scale to the appropriate aspect ratio, cropping
860 860
                     case 'crop':
861 861
                         $aspectRatio = ':force_original_aspect_ratio=increase'
862
-                            . ',crop=' . $options['width'] . ':' . $options['height'];
862
+                            . ',crop='.$options['width'].':'.$options['height'];
863 863
                         break;
864 864
                     // No aspect ratio scaling at all
865 865
                     default:
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
                 $sharpen = ',unsharp=5:5:1.0:5:5:0.0';
874 874
             }
875 875
             $ffmpegCmd .= ' -vf "scale='
876
-                . $options['width'] . ':' . $options['height']
876
+                . $options['width'].':'.$options['height']
877 877
                 . $aspectRatio
878 878
                 . $sharpen
879 879
                 . '"';
Please login to merge, or discard this patch.
src/services/ServicesTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
         // so we can't extract it from the passed in $config
37 37
         $majorVersion = '5';
38 38
         // Dev server container name & port are based on the major version of this plugin
39
-        $devPort = 3000 + (int)$majorVersion;
40
-        $versionName = 'v' . $majorVersion;
39
+        $devPort = 3000 + (int) $majorVersion;
40
+        $versionName = 'v'.$majorVersion;
41 41
         return [
42 42
             'components' => [
43 43
                 'transcode' => Transcode::class,
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
                     'class' => VitePluginService::class,
47 47
                     'assetClass' => TranscoderAsset::class,
48 48
                     'useDevServer' => true,
49
-                    'devServerInternal' => 'http://craft-transcoder-' . $versionName . '-buildchain-dev:' . $devPort,
50
-                    'devServerPublic' => 'http://localhost:' . $devPort,
49
+                    'devServerInternal' => 'http://craft-transcoder-'.$versionName.'-buildchain-dev:'.$devPort,
50
+                    'devServerPublic' => 'http://localhost:'.$devPort,
51 51
                     'errorEntry' => 'src/js/app.ts',
52 52
                     'checkDevServer' => true,
53 53
                 ],
Please login to merge, or discard this patch.