Passed
Push — v1 ( 9eeffa...1e580d )
by Andrew
06:36 queued 03:16
created
src/variables/TranscoderVariable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@
 block discarded – undo
147 147
     {
148 148
         $result = "";
149 149
         $filePath = parse_url($url, PHP_URL_PATH);
150
-        $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
150
+        $filePath = $_SERVER[ 'DOCUMENT_ROOT' ] . $filePath;
151 151
         if (file_exists($filePath)) {
152 152
             $urlParams = [
153 153
                 'url' => $url,
Please login to merge, or discard this patch.
src/models/Settings.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     public function init()
181 181
     {
182 182
         $tokens = [
183
-            '{DOCUMENT_ROOT}' => $_SERVER['DOCUMENT_ROOT'],
183
+            '{DOCUMENT_ROOT}' => $_SERVER[ 'DOCUMENT_ROOT' ],
184 184
         ];
185 185
         $this->transcoderPath = str_replace(array_keys($tokens), array_values($tokens), $this->transcoderPath);
186 186
     }
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
     public function rules()
192 192
     {
193 193
         return [
194
-            ['ffmpegPath', 'string'],
195
-            ['ffmpegPath', 'required'],
196
-            ['ffprobePath', 'string'],
197
-            ['ffprobePath', 'required'],
198
-            ['ffprobeOptions', 'string'],
199
-            ['ffprobeOptions', 'safe'],
200
-            ['transcoderPath', 'string'],
201
-            ['transcoderPath', 'required'],
202
-            ['transcoderUrl', 'string'],
203
-            ['transcoderUrl', 'required'],
204
-            ['useHashedNames', 'boolean'],
205
-            ['useHashedNames', 'default', 'value' => false],
206
-            ['videoEncoders', 'required'],
207
-            ['audioEncoders', 'required'],
208
-            ['defaultVideoOptions', 'required'],
209
-            ['defaultThumbnailOptions', 'required'],
210
-            ['defaultAudioOptions', 'required'],
194
+            [ 'ffmpegPath', 'string' ],
195
+            [ 'ffmpegPath', 'required' ],
196
+            [ 'ffprobePath', 'string' ],
197
+            [ 'ffprobePath', 'required' ],
198
+            [ 'ffprobeOptions', 'string' ],
199
+            [ 'ffprobeOptions', 'safe' ],
200
+            [ 'transcoderPath', 'string' ],
201
+            [ 'transcoderPath', 'required' ],
202
+            [ 'transcoderUrl', 'string' ],
203
+            [ 'transcoderUrl', 'required' ],
204
+            [ 'useHashedNames', 'boolean' ],
205
+            [ 'useHashedNames', 'default', 'value' => false ],
206
+            [ 'videoEncoders', 'required' ],
207
+            [ 'audioEncoders', 'required' ],
208
+            [ 'defaultVideoOptions', 'required' ],
209
+            [ 'defaultThumbnailOptions', 'required' ],
210
+            [ 'defaultAudioOptions', 'required' ],
211 211
         ];
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
src/Transcoder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         Event::on(
62 62
             CraftVariable::class,
63 63
             CraftVariable::EVENT_INIT,
64
-            function (Event $event) {
64
+            function(Event $event) {
65 65
                 /** @var CraftVariable $variable */
66 66
                 $variable = $event->sender;
67 67
                 $variable->set('transcoder', TranscoderVariable::class);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         Event::on(
73 73
             Assets::class,
74 74
             Assets::EVENT_GET_THUMB_PATH,
75
-            function (AssetThumbEvent $event) {
75
+            function(AssetThumbEvent $event) {
76 76
                 Craft::debug(
77 77
                     'Assets::EVENT_GET_THUMB_PATH',
78 78
                     __METHOD__
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
         Event::on(
95 95
             ClearCaches::class,
96 96
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
97
-            function (RegisterCacheOptionsEvent $event) {
98
-                $event->options[] = [
97
+            function(RegisterCacheOptionsEvent $event) {
98
+                $event->options[ ] = [
99 99
                     'key' => 'transcoder',
100 100
                     'label' => Craft::t('transcoder', 'Transcoder caches'),
101 101
                     'action' => Transcoder::$plugin->getSettings()->transcoderPath,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             Craft::t(
108 108
                 'transcoder',
109 109
                 '{name} plugin loaded',
110
-                ['name' => $this->name]
110
+                [ 'name' => $this->name ]
111 111
             ),
112 112
             __METHOD__
113 113
         );
Please login to merge, or discard this patch.
src/services/Transcode.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
         $filePath = $this->getAssetPath($filePath);
96 96
 
97 97
         if (!empty($filePath)) {
98
-            $destVideoPath = Craft::getAlias($settings['transcoderPath']);
98
+            $destVideoPath = Craft::getAlias($settings[ 'transcoderPath' ]);
99 99
 
100 100
             $videoOptions = $this->coalesceOptions("defaultVideoOptions", $videoOptions);
101 101
 
102 102
             // Get the video encoder presets to use
103
-            $videoEncoders = $settings['videoEncoders'];
104
-            $thisEncoder = $videoEncoders[$videoOptions['videoEncoder']];
103
+            $videoEncoders = $settings[ 'videoEncoders' ];
104
+            $thisEncoder = $videoEncoders[ $videoOptions[ 'videoEncoder' ] ];
105 105
 
106
-            $videoOptions['fileSuffix'] = $thisEncoder['fileSuffix'];
106
+            $videoOptions[ 'fileSuffix' ] = $thisEncoder[ 'fileSuffix' ];
107 107
 
108 108
             // Build the basic command for ffmpeg
109
-            $ffmpegCmd = $settings['ffmpegPath']
109
+            $ffmpegCmd = $settings[ 'ffmpegPath' ]
110 110
                 . ' -i ' . escapeshellarg($filePath)
111
-                . ' -vcodec ' . $thisEncoder['videoCodec']
112
-                . ' ' . $thisEncoder['videoCodecOptions']
111
+                . ' -vcodec ' . $thisEncoder[ 'videoCodec' ]
112
+                . ' ' . $thisEncoder[ 'videoCodecOptions' ]
113 113
                 . ' -bufsize 1000k'
114 114
                 . ' -threads 0';
115 115
 
116 116
             // Set the framerate if desired
117
-            if (!empty($videoOptions['videoFrameRate'])) {
118
-                $ffmpegCmd .= ' -r ' . $videoOptions['videoFrameRate'];
117
+            if (!empty($videoOptions[ 'videoFrameRate' ])) {
118
+                $ffmpegCmd .= ' -r ' . $videoOptions[ 'videoFrameRate' ];
119 119
             }
120 120
 
121 121
             // Set the bitrate if desired
122
-            if (!empty($videoOptions['videoBitRate'])) {
123
-                $ffmpegCmd .= ' -b:v ' . $videoOptions['videoBitRate'] . ' -maxrate ' . $videoOptions['videoBitRate'];
122
+            if (!empty($videoOptions[ 'videoBitRate' ])) {
123
+                $ffmpegCmd .= ' -b:v ' . $videoOptions[ 'videoBitRate' ] . ' -maxrate ' . $videoOptions[ 'videoBitRate' ];
124 124
             }
125 125
 
126 126
             // Adjust the scaling if desired
@@ -130,25 +130,25 @@  discard block
 block discarded – undo
130 130
             );
131 131
 
132 132
             // Handle any audio transcoding
133
-            if (empty($videoOptions['audioBitRate'])
134
-                && empty($videoOptions['audioSampleRate'])
135
-                && empty($videoOptions['audioChannels'])
133
+            if (empty($videoOptions[ 'audioBitRate' ])
134
+                && empty($videoOptions[ 'audioSampleRate' ])
135
+                && empty($videoOptions[ 'audioChannels' ])
136 136
             ) {
137 137
                 // Just copy the audio if no options are provided
138 138
                 $ffmpegCmd .= ' -c:a copy';
139 139
             } else {
140 140
                 // Do audio transcoding based on the settings
141
-                $ffmpegCmd .= ' -acodec ' . $thisEncoder['audioCodec'];
142
-                if (!empty($videoOptions['audioBitRate'])) {
143
-                    $ffmpegCmd .= ' -b:a ' . $videoOptions['audioBitRate'];
141
+                $ffmpegCmd .= ' -acodec ' . $thisEncoder[ 'audioCodec' ];
142
+                if (!empty($videoOptions[ 'audioBitRate' ])) {
143
+                    $ffmpegCmd .= ' -b:a ' . $videoOptions[ 'audioBitRate' ];
144 144
                 }
145
-                if (!empty($videoOptions['audioSampleRate'])) {
146
-                    $ffmpegCmd .= ' -ar ' . $videoOptions['audioSampleRate'];
145
+                if (!empty($videoOptions[ 'audioSampleRate' ])) {
146
+                    $ffmpegCmd .= ' -ar ' . $videoOptions[ 'audioSampleRate' ];
147 147
                 }
148
-                if (!empty($videoOptions['audioChannels'])) {
149
-                    $ffmpegCmd .= ' -ac ' . $videoOptions['audioChannels'];
148
+                if (!empty($videoOptions[ 'audioChannels' ])) {
149
+                    $ffmpegCmd .= ' -ac ' . $videoOptions[ 'audioChannels' ];
150 150
                 }
151
-                $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
151
+                $ffmpegCmd .= ' ' . $thisEncoder[ 'audioCodecOptions' ];
152 152
             }
153 153
 
154 154
             // Create the directory if it isn't there already
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             // Assemble the destination path and final ffmpeg command
165 165
             $destVideoPath = $destVideoPath . $destVideoFile;
166 166
             $ffmpegCmd .= ' -f '
167
-                . $thisEncoder['fileFormat']
167
+                . $thisEncoder[ 'fileFormat' ]
168 168
                 . ' -y ' . escapeshellarg($destVideoPath)
169 169
                 . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
170 170
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
             // If the video file already exists and hasn't been modified, return it.  Otherwise, start it transcoding
185 185
             if (file_exists($destVideoPath) && (filemtime($destVideoPath) >= filemtime($filePath))) {
186
-                $result = Craft::getAlias($settings['transcoderUrl']) . $destVideoFile;
186
+                $result = Craft::getAlias($settings[ 'transcoderUrl' ]) . $destVideoFile;
187 187
             } else {
188 188
                 // Kick off the transcoding
189 189
                 $pid = $this->executeShellCommand($ffmpegCmd);
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
         $filePath = $this->getAssetPath($filePath);
217 217
 
218 218
         if (!empty($filePath)) {
219
-            $destThumbnailPath = Craft::getAlias($settings['transcoderPath']);
219
+            $destThumbnailPath = Craft::getAlias($settings[ 'transcoderPath' ]);
220 220
 
221 221
             $thumbnailOptions = $this->coalesceOptions("defaultThumbnailOptions", $thumbnailOptions);
222 222
 
223 223
             // Build the basic command for ffmpeg
224
-            $ffmpegCmd = $settings['ffmpegPath']
224
+            $ffmpegCmd = $settings[ 'ffmpegPath' ]
225 225
                 . ' -i ' . escapeshellarg($filePath)
226 226
                 . ' -vcodec mjpeg'
227 227
                 . ' -vframes 1';
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
             );
234 234
 
235 235
             // Set the timecode to get the thumbnail from if desired
236
-            if (!empty($thumbnailOptions['timeInSecs'])) {
237
-                $timeCode = gmdate("H:i:s", $thumbnailOptions['timeInSecs']);
236
+            if (!empty($thumbnailOptions[ 'timeInSecs' ])) {
237
+                $timeCode = gmdate("H:i:s", $thumbnailOptions[ 'timeInSecs' ]);
238 238
                 $ffmpegCmd .= ' -ss ' . $timeCode . '.00';
239 239
             }
240 240
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             if ($asPath) {
265 265
                 $result = $destThumbnailPath;
266 266
             } else {
267
-                $result = Craft::getAlias($settings['transcoderUrl']) . $destThumbnailFile;
267
+                $result = Craft::getAlias($settings[ 'transcoderUrl' ]) . $destThumbnailFile;
268 268
             }
269 269
         }
270 270
 
@@ -288,37 +288,37 @@  discard block
 block discarded – undo
288 288
         $filePath = $this->getAssetPath($filePath);
289 289
 
290 290
         if (!empty($filePath)) {
291
-            $destAudioPath = Craft::getAlias($settings['transcoderPath']);
291
+            $destAudioPath = Craft::getAlias($settings[ 'transcoderPath' ]);
292 292
 
293 293
             $audioOptions = $this->coalesceOptions("defaultAudioOptions", $audioOptions);
294 294
 
295 295
             // Get the audio encoder presets to use
296
-            $audioEncoders = $settings['audioEncoders'];
297
-            $thisEncoder = $audioEncoders[$audioOptions['audioEncoder']];
296
+            $audioEncoders = $settings[ 'audioEncoders' ];
297
+            $thisEncoder = $audioEncoders[ $audioOptions[ 'audioEncoder' ] ];
298 298
 
299
-            $audioOptions['fileSuffix'] = $thisEncoder['fileSuffix'];
299
+            $audioOptions[ 'fileSuffix' ] = $thisEncoder[ 'fileSuffix' ];
300 300
 
301 301
             // Build the basic command for ffmpeg
302
-            $ffmpegCmd = $settings['ffmpegPath']
302
+            $ffmpegCmd = $settings[ 'ffmpegPath' ]
303 303
                 . ' -i ' . escapeshellarg($filePath)
304
-                . ' -acodec ' . $thisEncoder['audioCodec']
305
-                . ' ' . $thisEncoder['audioCodecOptions']
304
+                . ' -acodec ' . $thisEncoder[ 'audioCodec' ]
305
+                . ' ' . $thisEncoder[ 'audioCodecOptions' ]
306 306
                 . ' -bufsize 1000k'
307 307
                 . ' -threads 0';
308 308
 
309 309
             // Set the bitrate if desired
310
-            if (!empty($audioOptions['audioBitRate'])) {
311
-                $ffmpegCmd .= ' -b:a ' . $audioOptions['audioBitRate'];
310
+            if (!empty($audioOptions[ 'audioBitRate' ])) {
311
+                $ffmpegCmd .= ' -b:a ' . $audioOptions[ 'audioBitRate' ];
312 312
             }
313 313
             // Set the sample rate if desired
314
-            if (!empty($audioOptions['audioSampleRate'])) {
315
-                $ffmpegCmd .= ' -ar ' . $audioOptions['audioSampleRate'];
314
+            if (!empty($audioOptions[ 'audioSampleRate' ])) {
315
+                $ffmpegCmd .= ' -ar ' . $audioOptions[ 'audioSampleRate' ];
316 316
             }
317 317
             // Set the audio channels if desired
318
-            if (!empty($audioOptions['audioChannels'])) {
319
-                $ffmpegCmd .= ' -ac ' . $audioOptions['audioChannels'];
318
+            if (!empty($audioOptions[ 'audioChannels' ])) {
319
+                $ffmpegCmd .= ' -ac ' . $audioOptions[ 'audioChannels' ];
320 320
             }
321
-            $ffmpegCmd .= ' ' . $thisEncoder['audioCodecOptions'];
321
+            $ffmpegCmd .= ' ' . $thisEncoder[ 'audioCodecOptions' ];
322 322
 
323 323
 
324 324
             // Create the directory if it isn't there already
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
             // Assemble the destination path and final ffmpeg command
335 335
             $destAudioPath = $destAudioPath . $destAudioFile;
336 336
             $ffmpegCmd .= ' -f '
337
-                . $thisEncoder['fileFormat']
337
+                . $thisEncoder[ 'fileFormat' ]
338 338
                 . ' -y ' . escapeshellarg($destAudioPath)
339 339
                 . ' 1> ' . $progressFile . ' 2>&1 & echo $!';
340 340
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
             // If the audio file already exists and hasn't been modified, return it.  Otherwise, start it transcoding
355 355
             if (file_exists($destAudioPath) && (filemtime($destAudioPath) >= filemtime($filePath))) {
356
-                $result = Craft::getAlias($settings['transcoderUrl']) . $destAudioFile;
356
+                $result = Craft::getAlias($settings[ 'transcoderUrl' ]) . $destAudioFile;
357 357
             } else {
358 358
                 // Kick off the transcoding
359 359
                 $pid = $this->executeShellCommand($ffmpegCmd);
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
         if (!empty($filePath)) {
386 386
             // Build the basic command for ffprobe
387
-            $ffprobeOptions = $settings['ffprobeOptions'];
388
-            $ffprobeCmd = $settings['ffprobePath']
387
+            $ffprobeOptions = $settings[ 'ffprobeOptions' ];
388
+            $ffprobeCmd = $settings[ 'ffprobePath' ]
389 389
                 . ' ' . $ffprobeOptions
390 390
                 . ' ' . escapeshellarg($filePath);
391 391
 
@@ -396,24 +396,24 @@  discard block
 block discarded – undo
396 396
 
397 397
             // Trim down the arrays to just a summary
398 398
             if ($summary && !empty($result)) {
399
-                $summaryResult = [];
399
+                $summaryResult = [ ];
400 400
                 foreach ($result as $topLevelKey => $topLevelValue) {
401 401
                     switch ($topLevelKey) {
402 402
                         // Format info
403 403
                         case "format":
404
-                            foreach ($this->infoSummary['format'] as $settingKey => $settingValue) {
405
-                                if (!empty($topLevelValue[$settingKey])) {
406
-                                    $summaryResult[$settingValue] = $topLevelValue[$settingKey];
404
+                            foreach ($this->infoSummary[ 'format' ] as $settingKey => $settingValue) {
405
+                                if (!empty($topLevelValue[ $settingKey ])) {
406
+                                    $summaryResult[ $settingValue ] = $topLevelValue[ $settingKey ];
407 407
                                 }
408 408
                             }
409 409
                             break;
410 410
                         // Stream info
411 411
                         case "streams":
412 412
                             foreach ($topLevelValue as $stream) {
413
-                                $infoSummaryType = $stream['codec_type'];
414
-                                foreach ($this->infoSummary[$infoSummaryType] as $settingKey => $settingValue) {
415
-                                    if (!empty($stream[$settingKey])) {
416
-                                        $summaryResult[$settingValue] = $stream[$settingKey];
413
+                                $infoSummaryType = $stream[ 'codec_type' ];
414
+                                foreach ($this->infoSummary[ $infoSummaryType ] as $settingKey => $settingValue) {
415
+                                    if (!empty($stream[ $settingKey ])) {
416
+                                        $summaryResult[ $settingValue ] = $stream[ $settingKey ];
417 417
                                     }
418 418
                                 }
419 419
                             }
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
                     }
425 425
                 }
426 426
                 // Handle cases where the framerate is returned as XX/YY
427
-                if (!empty($summaryResult['videoFrameRate'])
428
-                    && (strpos($summaryResult['videoFrameRate'], '/') !== false)
427
+                if (!empty($summaryResult[ 'videoFrameRate' ])
428
+                    && (strpos($summaryResult[ 'videoFrameRate' ], '/') !== false)
429 429
                 ) {
430
-                    $parts = explode('/', $summaryResult['videoFrameRate']);
431
-                    $summaryResult['videoFrameRate'] = floatval($parts[0]) / floatval($parts[1]);
430
+                    $parts = explode('/', $summaryResult[ 'videoFrameRate' ]);
431
+                    $summaryResult[ 'videoFrameRate' ] = floatval($parts[ 0 ]) / floatval($parts[ 1 ]);
432 432
                 }
433 433
                 $result = $summaryResult;
434 434
             }
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
         $videoOptions = $this->coalesceOptions("defaultVideoOptions", $videoOptions);
452 452
 
453 453
         // Get the video encoder presets to use
454
-        $videoEncoders = $settings['videoEncoders'];
455
-        $thisEncoder = $videoEncoders[$videoOptions['videoEncoder']];
454
+        $videoEncoders = $settings[ 'videoEncoders' ];
455
+        $thisEncoder = $videoEncoders[ $videoOptions[ 'videoEncoder' ] ];
456 456
 
457
-        $videoOptions['fileSuffix'] = $thisEncoder['fileSuffix'];
457
+        $videoOptions[ 'fileSuffix' ] = $thisEncoder[ 'fileSuffix' ];
458 458
 
459 459
         $result = $this->getFilename($filePath, $videoOptions);
460 460
 
@@ -475,10 +475,10 @@  discard block
 block discarded – undo
475 475
         $audioOptions = $this->coalesceOptions("defaultAudioOptions", $audioOptions);
476 476
 
477 477
         // Get the video encoder presets to use
478
-        $audioEncoders = $settings['audioEncoders'];
479
-        $thisEncoder = $audioEncoders[$audioOptions['audioEncoder']];
478
+        $audioEncoders = $settings[ 'audioEncoders' ];
479
+        $thisEncoder = $audioEncoders[ $audioOptions[ 'audioEncoder' ] ];
480 480
 
481
-        $audioOptions['fileSuffix'] = $thisEncoder['fileSuffix'];
481
+        $audioOptions[ 'fileSuffix' ] = $thisEncoder[ 'fileSuffix' ];
482 482
 
483 483
         $result = $this->getFilename($filePath, $audioOptions);
484 484
 
@@ -523,18 +523,18 @@  discard block
 block discarded – undo
523 523
         $error = '';
524 524
         if ($validator->validate($filePath, $error)) {
525 525
             $urlParts = parse_url($filePath);
526
-            $pathParts = pathinfo($urlParts['path']);
526
+            $pathParts = pathinfo($urlParts[ 'path' ]);
527 527
         } else {
528 528
             $pathParts = pathinfo($filePath);
529 529
         }
530
-        $fileName = $pathParts['filename'];
530
+        $fileName = $pathParts[ 'filename' ];
531 531
 
532 532
         // Add our options to the file name
533 533
         foreach ($options as $key => $value) {
534 534
             if (!empty($value)) {
535 535
                 $suffix = "";
536
-                if (!empty($this->suffixMap[$key])) {
537
-                    $suffix = $this->suffixMap[$key];
536
+                if (!empty($this->suffixMap[ $key ])) {
537
+                    $suffix = $this->suffixMap[ $key ];
538 538
                 }
539 539
                 if (is_bool($value)) {
540 540
                     $value = $value ? $key : 'no' . $key;
@@ -545,10 +545,10 @@  discard block
 block discarded – undo
545 545
             }
546 546
         }
547 547
         // See if we should use a hash instead
548
-        if ($settings['useHashedNames']) {
549
-            $fileName = $pathParts['filename'] . md5($fileName);
548
+        if ($settings[ 'useHashedNames' ]) {
549
+            $fileName = $pathParts[ 'filename' ] . md5($fileName);
550 550
         }
551
-        $fileName .= $options['fileSuffix'];
551
+        $fileName .= $options[ 'fileSuffix' ];
552 552
 
553 553
         return $fileName;
554 554
     }
@@ -619,39 +619,39 @@  discard block
 block discarded – undo
619 619
      */
620 620
     protected function addScalingFfmpegArgs($options, $ffmpegCmd): string
621 621
     {
622
-        if (!empty($options['width']) && !empty($options['height'])) {
622
+        if (!empty($options[ 'width' ]) && !empty($options[ 'height' ])) {
623 623
             // Handle "none", "crop", and "letterbox" aspectRatios
624 624
             $aspectRatio = "";
625
-            if (!empty($options['aspectRatio'])) {
626
-                switch ($options['aspectRatio']) {
625
+            if (!empty($options[ 'aspectRatio' ])) {
626
+                switch ($options[ 'aspectRatio' ]) {
627 627
                     // Scale to the appropriate aspect ratio, padding
628 628
                     case "letterbox":
629 629
                         $letterboxColor = "";
630
-                        if (!empty($options['letterboxColor'])) {
631
-                            $letterboxColor = ":color=" . $options['letterboxColor'];
630
+                        if (!empty($options[ 'letterboxColor' ])) {
631
+                            $letterboxColor = ":color=" . $options[ 'letterboxColor' ];
632 632
                         }
633 633
                         $aspectRatio = ':force_original_aspect_ratio=decrease'
634
-                            . ',pad=' . $options['width'] . ':' . $options['height'] . ':(ow-iw)/2:(oh-ih)/2'
634
+                            . ',pad=' . $options[ 'width' ] . ':' . $options[ 'height' ] . ':(ow-iw)/2:(oh-ih)/2'
635 635
                             . $letterboxColor;
636 636
                         break;
637 637
                     // Scale to the appropriate aspect ratio, cropping
638 638
                     case "crop":
639 639
                         $aspectRatio = ':force_original_aspect_ratio=increase'
640
-                            . ',crop=' . $options['width'] . ':' . $options['height'];
640
+                            . ',crop=' . $options[ 'width' ] . ':' . $options[ 'height' ];
641 641
                         break;
642 642
                     // No aspect ratio scaling at all
643 643
                     default:
644 644
                         $aspectRatio = ':force_original_aspect_ratio=disable';
645
-                        $options['aspectRatio'] = "none";
645
+                        $options[ 'aspectRatio' ] = "none";
646 646
                         break;
647 647
                 }
648 648
             }
649 649
             $sharpen = "";
650
-            if (!empty($options['sharpen']) && ($options['sharpen'] !== false)) {
650
+            if (!empty($options[ 'sharpen' ]) && ($options[ 'sharpen' ] !== false)) {
651 651
                 $sharpen = ',unsharp=5:5:1.0:5:5:0.0';
652 652
             }
653 653
             $ffmpegCmd .= ' -vf "scale='
654
-                . $options['width'] . ':' . $options['height']
654
+                . $options[ 'width' ] . ':' . $options[ 'height' ]
655 655
                 . $aspectRatio
656 656
                 . $sharpen
657 657
                 . '"';
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
     {
673 673
         // Default options
674 674
         $settings = Transcoder::$plugin->getSettings();
675
-        $defaultOptions = $settings[$defaultName];
675
+        $defaultOptions = $settings[ $defaultName ];
676 676
 
677 677
         // Coalesce the passed in $options with the $defaultOptions
678 678
         $options = array_merge($defaultOptions, $options);
Please login to merge, or discard this patch.
src/controllers/DefaultController.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
     public function actionDownloadFile($url)
52 52
     {
53 53
         $filePath = parse_url($url, PHP_URL_PATH);
54
-        $filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
54
+        $filePath = $_SERVER[ 'DOCUMENT_ROOT' ] . $filePath;
55 55
         Craft::$app->getResponse()->sendFile(
56 56
             $filePath,
57 57
             null,
58
-            ['inline' => false]
58
+            [ 'inline' => false ]
59 59
         );
60 60
         Craft::$app->end();
61 61
     }
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function actionProgress($filename)
76 76
     {
77
-        $result = [];
77
+        $result = [ ];
78 78
         $progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . ".progress";
79 79
         if (file_exists($progressFile)) {
80 80
             $content = @file_get_contents($progressFile);
81 81
             if ($content) {
82 82
                 // get duration of source
83 83
                 preg_match("/Duration: (.*?), start:/", $content, $matches);
84
-                $rawDuration = $matches[1];
84
+                $rawDuration = $matches[ 1 ];
85 85
 
86 86
                 // rawDuration is in 00:00:00.00 format. This converts it to seconds.
87 87
                 $ar = array_reverse(explode(":", $rawDuration));
88
-                $duration = floatval($ar[0]);
89
-                if (!empty($ar[1])) {
90
-                    $duration += intval($ar[1]) * 60;
88
+                $duration = floatval($ar[ 0 ]);
89
+                if (!empty($ar[ 1 ])) {
90
+                    $duration += intval($ar[ 1 ]) * 60;
91 91
                 }
92
-                if (!empty($ar[2])) {
93
-                    $duration += intval($ar[2]) * 60 * 60;
92
+                if (!empty($ar[ 2 ])) {
93
+                    $duration += intval($ar[ 2 ]) * 60 * 60;
94 94
                 }
95 95
 
96 96
                 // Get the time in the file that is already encoded
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 
105 105
                 //rawTime is in 00:00:00.00 format. This converts it to seconds.
106 106
                 $ar = array_reverse(explode(":", $rawTime));
107
-                $time = floatval($ar[0]);
108
-                if (!empty($ar[1])) {
109
-                    $time += intval($ar[1]) * 60;
107
+                $time = floatval($ar[ 0 ]);
108
+                if (!empty($ar[ 1 ])) {
109
+                    $time += intval($ar[ 1 ]) * 60;
110 110
                 }
111
-                if (!empty($ar[2])) {
112
-                    $time += intval($ar[2]) * 60 * 60;
111
+                if (!empty($ar[ 2 ])) {
112
+                    $time += intval($ar[ 2 ]) * 60 * 60;
113 113
                 }
114 114
 
115 115
                 //calculate the progress
Please login to merge, or discard this patch.