Passed
Push — develop ( afd169...ad1149 )
by Andrew
05:20 queued 43s
created
src/listeners/GetCraftQLSchema.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@
 block discarded – undo
39 39
 
40 40
         // Primary getter functions
41 41
         $fieldObject->addStringField('src')
42
-            ->arguments(function (\markhuot\CraftQL\Builders\Field $field) {
42
+            ->arguments(function(\markhuot\CraftQL\Builders\Field $field) {
43 43
                 $field->addIntArgument('width');
44 44
             })
45
-            ->resolve(function ($root, $args) {
45
+            ->resolve(function($root, $args) {
46 46
                 return $root->src(@$args['width'] ?: 0);
47 47
             });
48 48
         $fieldObject->addField('srcUrls')
49 49
             ->lists()
50 50
             ->type($srcObject)
51
-            ->resolve(function ($root, $args) {
51
+            ->resolve(function($root, $args) {
52 52
                 $result = [];
53 53
                 foreach ($root->optimizedImageUrls as $width => $url) {
54 54
                     $result[] = ['width' => $width, 'url' => $url];
Please login to merge, or discard this patch.
src/gql/types/generators/OptimizedImagesGenerator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -261,12 +261,12 @@
 block discarded – undo
261 261
             ?: GqlEntityRegistry::createEntity($typeName, new OptimizedImagesType([
262 262
                 'name' => $typeName,
263 263
                 'description' => 'This entity has all the OptimizedImages properties',
264
-                'fields' => function () use ($optimizedImagesFields) {
264
+                'fields' => function() use ($optimizedImagesFields) {
265 265
                     return $optimizedImagesFields;
266 266
                 },
267 267
             ]));
268 268
 
269
-        TypeLoader::registerType($typeName, function () use ($optimizedImagesType) {
269
+        TypeLoader::registerType($typeName, function() use ($optimizedImagesType) {
270 270
             return $optimizedImagesType;
271 271
         });
272 272
 
Please login to merge, or discard this patch.
src/services/Optimize.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
             $vars,
274 274
             $minifier
275 275
         );
276
-        $content = (string)$content;
276
+        $content = (string) $content;
277 277
         if ($scriptAttrs !== null) {
278 278
             $attrs = array_merge([
279 279
             ],
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $vars,
309 309
             $minifier
310 310
         );
311
-        $content = (string)$content;
311
+        $content = (string) $content;
312 312
         if ($scriptAttrs !== null) {
313 313
             $attrs = array_merge([
314 314
             ],
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
                 . '%';
373 373
             Craft::info($message, __METHOD__);
374 374
             if (Craft::$app instanceof ConsoleApplication) {
375
-                echo $message . PHP_EOL;
375
+                echo $message.PHP_EOL;
376 376
             }
377 377
             // Create any image variants
378 378
             $this->createImageVariants(
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
      */
411 411
     public function saveTransformToTempFile(AssetTransformIndex $index, Image $image): string
412 412
     {
413
-        $tempFilename = uniqid(pathinfo($index->filename, PATHINFO_FILENAME), true) . '.' . $index->detectedFormat;
414
-        $tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename;
413
+        $tempFilename = uniqid(pathinfo($index->filename, PATHINFO_FILENAME), true).'.'.$index->detectedFormat;
414
+        $tempPath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$tempFilename;
415 415
         try {
416 416
             $image->saveAs($tempPath);
417 417
         } catch (ImageException $e) {
418
-            Craft::error('Transformed image save failed: ' . $e->getMessage(), __METHOD__);
418
+            Craft::error('Transformed image save failed: '.$e->getMessage(), __METHOD__);
419 419
         }
420
-        Craft::info('Transformed image saved to: ' . $tempPath, __METHOD__);
420
+        Craft::info('Transformed image saved to: '.$tempPath, __METHOD__);
421 421
 
422 422
         return $tempPath;
423 423
     }
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
                             . '%';
530 530
                         Craft::info($message, __METHOD__);
531 531
                         if (Craft::$app instanceof ConsoleApplication) {
532
-                            echo $message . PHP_EOL;
532
+                            echo $message.PHP_EOL;
533 533
                         }
534 534
                         // Copy the image variant into place
535 535
                         $this->copyImageVariantToVolume(
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
                 // Handle auto-sharpening scaled down images
629 629
                 if ($settings->autoSharpenScaledImages) {
630 630
                     // See if the image has been scaled >= 50%
631
-                    $widthScale = (int)(($image->getWidth() / $asset->getWidth()) * 100);
632
-                    $heightScale = (int)(($image->getHeight() / $asset->getHeight()) * 100);
633
-                    if (($widthScale >= (int)$settings->sharpenScaledImagePercentage) || ($heightScale >= (int)$settings->sharpenScaledImagePercentage)) {
631
+                    $widthScale = (int) (($image->getWidth() / $asset->getWidth()) * 100);
632
+                    $heightScale = (int) (($image->getHeight() / $asset->getHeight()) * 100);
633
+                    if (($widthScale >= (int) $settings->sharpenScaledImagePercentage) || ($heightScale >= (int) $settings->sharpenScaledImagePercentage)) {
634 634
                         $imagineImage->effects()
635 635
                             ->sharpen();
636 636
                         Craft::debug(
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
                 . escapeshellarg($tempPath);
686 686
             // Execute the command
687 687
             $shellOutput = $this->executeShellCommand($cmd);
688
-            Craft::info($cmd . "\n" . $shellOutput, __METHOD__);
688
+            Craft::info($cmd."\n".$shellOutput, __METHOD__);
689 689
         } else {
690 690
             Craft::error(
691 691
                 $thisProcessor['commandPath']
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
         // Make sure the command exists
738 738
         if (is_file($variantCreatorCommand['commandPath'])) {
739 739
             // Get the output file for this image variant
740
-            $outputPath .= '.' . $variantCreatorCommand['imageVariantExtension'];
740
+            $outputPath .= '.'.$variantCreatorCommand['imageVariantExtension'];
741 741
             // Set any options for the command
742 742
             $commandOptions = '';
743 743
             if (!empty($variantCreatorCommand['commandOptions'])) {
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
                 . escapeshellarg($tempPath);
773 773
             // Execute the command
774 774
             $shellOutput = $this->executeShellCommand($cmd);
775
-            Craft::info($cmd . "\n" . $shellOutput, __METHOD__);
775
+            Craft::info($cmd."\n".$shellOutput, __METHOD__);
776 776
         } else {
777 777
             Craft::error(
778 778
                 $variantCreatorCommand['commandPath']
@@ -810,23 +810,23 @@  discard block
 block discarded – undo
810 810
                         } catch (InvalidConfigException $e) {
811 811
                             $volume = null;
812 812
                             Craft::error(
813
-                                'Asset volume error: ' . $e->getMessage(),
813
+                                'Asset volume error: '.$e->getMessage(),
814 814
                                 __METHOD__
815 815
                             );
816 816
                         }
817 817
                         try {
818
-                            $variantPath = $asset->getFolder()->path . $assetTransforms->getTransformSubpath(
818
+                            $variantPath = $asset->getFolder()->path.$assetTransforms->getTransformSubpath(
819 819
                                     $asset,
820 820
                                     $transformIndex
821 821
                                 );
822 822
                         } catch (InvalidConfigException $e) {
823 823
                             $variantPath = '';
824 824
                             Craft::error(
825
-                                'Asset folder does not exist: ' . $e->getMessage(),
825
+                                'Asset folder does not exist: '.$e->getMessage(),
826 826
                                 __METHOD__
827 827
                             );
828 828
                         }
829
-                        $variantPath .= '.' . $variantCreatorCommand['imageVariantExtension'];
829
+                        $variantPath .= '.'.$variantCreatorCommand['imageVariantExtension'];
830 830
                         // Delete the variant file in case it is stale
831 831
                         try {
832 832
                             $volume->deleteFile($variantPath);
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
                             // We're fine with that.
835 835
                         }
836 836
                         Craft::info(
837
-                            'Deleted variant: ' . $variantPath,
837
+                            'Deleted variant: '.$variantPath,
838 838
                             __METHOD__
839 839
                         );
840 840
                     }
@@ -864,21 +864,21 @@  discard block
 block discarded – undo
864 864
             } catch (InvalidConfigException $e) {
865 865
                 $volume = null;
866 866
                 Craft::error(
867
-                    'Asset volume error: ' . $e->getMessage(),
867
+                    'Asset volume error: '.$e->getMessage(),
868 868
                     __METHOD__
869 869
                 );
870 870
             }
871 871
             $assetTransforms = Craft::$app->getAssetTransforms();
872 872
             try {
873
-                $transformPath = $asset->getFolder()->path . $assetTransforms->getTransformSubpath($asset, $index);
873
+                $transformPath = $asset->getFolder()->path.$assetTransforms->getTransformSubpath($asset, $index);
874 874
             } catch (InvalidConfigException $e) {
875 875
                 $transformPath = '';
876 876
                 Craft::error(
877
-                    'Error getting asset folder: ' . $e->getMessage(),
877
+                    'Error getting asset folder: '.$e->getMessage(),
878 878
                     __METHOD__
879 879
                 );
880 880
             }
881
-            $variantPath = $transformPath . '.' . $variantCreatorCommand['imageVariantExtension'];
881
+            $variantPath = $transformPath.'.'.$variantCreatorCommand['imageVariantExtension'];
882 882
 
883 883
             // Delete the variant file in case it is stale
884 884
             try {
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
             }
889 889
 
890 890
             Craft::info(
891
-                'Variant output path: ' . $outputPath . ' - Variant path: ' . $variantPath,
891
+                'Variant output path: '.$outputPath.' - Variant path: '.$variantPath,
892 892
                 __METHOD__
893 893
             );
894 894
 
@@ -926,9 +926,9 @@  discard block
 block discarded – undo
926 926
     protected function swapPathExtension(string $path, string $extension): string
927 927
     {
928 928
         $pathParts = pathinfo($path);
929
-        $newPath = $pathParts['filename'] . '.' . $extension;
929
+        $newPath = $pathParts['filename'].'.'.$extension;
930 930
         if (!empty($pathParts['dirname']) && $pathParts['dirname'] !== '.') {
931
-            $newPath = $pathParts['dirname'] . DIRECTORY_SEPARATOR . $newPath;
931
+            $newPath = $pathParts['dirname'].DIRECTORY_SEPARATOR.$newPath;
932 932
             $newPath = preg_replace('#/+#', '/', $newPath);
933 933
         }
934 934
 
Please login to merge, or discard this patch.
src/fields/OptimizedImages.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
         $sizesWrapperId = Craft::$app->getView()->namespaceInputId('sizes-wrapper');
327 327
         $view = Craft::$app->getView();
328 328
         $view->registerJs(
329
-            'document.addEventListener("vite-script-loaded", function (e) {' .
330
-            'if (e.detail.path === "../src/web/assets/src/js/OptimizedImagesField.js") {' .
331
-            'new Craft.OptimizedImagesInput(' .
332
-            '"' . $namespacedId . '", ' .
333
-            '"' . $namespacePrefix . '",' .
334
-            '"' . $sizesWrapperId . '"' .
335
-            ');' .
336
-            '}' .
329
+            'document.addEventListener("vite-script-loaded", function (e) {'.
330
+            'if (e.detail.path === "../src/web/assets/src/js/OptimizedImagesField.js") {'.
331
+            'new Craft.OptimizedImagesInput('.
332
+            '"'.$namespacedId.'", '.
333
+            '"'.$namespacePrefix.'",'.
334
+            '"'.$sizesWrapperId.'"'.
335
+            ');'.
336
+            '}'.
337 337
             '});'
338 338
         );
339 339
 
@@ -407,12 +407,12 @@  discard block
 block discarded – undo
407 407
             $jsonVars = Json::encode($jsonVars);
408 408
             $view = Craft::$app->getView();
409 409
             $view->registerJs(
410
-                'document.addEventListener("vite-script-loaded", function (e) {' .
411
-                'if (e.detail.path === "../src/web/assets/src/js/OptimizedImagesField.js") {' .
412
-                "$('#{$nameSpaceId}-field').ImageOptimizeOptimizedImages(" .
413
-                $jsonVars .
414
-                ");" .
415
-                '}' .
410
+                'document.addEventListener("vite-script-loaded", function (e) {'.
411
+                'if (e.detail.path === "../src/web/assets/src/js/OptimizedImagesField.js") {'.
412
+                "$('#{$nameSpaceId}-field').ImageOptimizeOptimizedImages(".
413
+                $jsonVars.
414
+                ");".
415
+                '}'.
416 416
                 '});'
417 417
             );
418 418
 
Please login to merge, or discard this patch.
src/helpers/PluginTemplate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
         string $minifier = null
63 63
     ): string
64 64
     {
65
-        $template = 'image-optimize/' . $templatePath;
65
+        $template = 'image-optimize/'.$templatePath;
66 66
         $oldMode = Craft::$app->view->getTemplateMode();
67 67
         // Look for the template on the frontend first
68 68
         try {
Please login to merge, or discard this patch.
src/validators/EmbeddedModelValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
                         $model->addError(
42 42
                             $attribute,
43 43
                             Craft::t('image-optimize', 'Object failed to validate')
44
-                            . '-' . $attributeError . ' - ' . $valueError
44
+                            . '-'.$attributeError.' - '.$valueError
45 45
                         );
46 46
                     }
47 47
                 }
Please login to merge, or discard this patch.
src/ImageOptimize.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         Event::on(
259 259
             CraftVariable::class,
260 260
             CraftVariable::EVENT_INIT,
261
-            function (Event $event) {
261
+            function(Event $event) {
262 262
                 /** @var CraftVariable $variable */
263 263
                 $variable = $event->sender;
264 264
                 $variable->set('imageOptimize', [
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         Event::on(
273 273
             Fields::class,
274 274
             Fields::EVENT_REGISTER_FIELD_TYPES,
275
-            function (RegisterComponentTypesEvent $event) {
275
+            function(RegisterComponentTypesEvent $event) {
276 276
                 Craft::debug(
277 277
                     'Fields::EVENT_REGISTER_FIELD_TYPES',
278 278
                     __METHOD__
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
             Event::on(
287 287
                 Utilities::class,
288 288
                 Utilities::EVENT_REGISTER_UTILITY_TYPES,
289
-                function (RegisterComponentTypesEvent $event) {
289
+                function(RegisterComponentTypesEvent $event) {
290 290
                     $event->types[] = ImageOptimizeUtility::class;
291 291
                 }
292 292
             );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         Event::on(
323 323
             Assets::class,
324 324
             Assets::EVENT_GET_ASSET_URL,
325
-            function (GetAssetUrlEvent $event) {
325
+            function(GetAssetUrlEvent $event) {
326 326
                 Craft::debug(
327 327
                     'Assets::EVENT_GET_ASSET_URL',
328 328
                     __METHOD__
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         Event::on(
339 339
             Assets::class,
340 340
             Assets::EVENT_GET_ASSET_THUMB_URL,
341
-            function (GetAssetThumbUrlEvent $event) {
341
+            function(GetAssetThumbUrlEvent $event) {
342 342
                 Craft::debug(
343 343
                     'Assets::EVENT_GET_ASSET_THUMB_URL',
344 344
                     __METHOD__
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         Event::on(
355 355
             AssetTransforms::class,
356 356
             AssetTransforms::EVENT_GENERATE_TRANSFORM,
357
-            function (GenerateTransformEvent $event) {
357
+            function(GenerateTransformEvent $event) {
358 358
                 Craft::debug(
359 359
                     'AssetTransforms::EVENT_GENERATE_TRANSFORM',
360 360
                     __METHOD__
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         Event::on(
371 371
             AssetTransforms::class,
372 372
             AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS,
373
-            function (AssetTransformImageEvent $event) {
373
+            function(AssetTransformImageEvent $event) {
374 374
                 Craft::debug(
375 375
                     'AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS',
376 376
                     __METHOD__
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         Event::on(
387 387
             Assets::class,
388 388
             Assets::EVENT_BEFORE_REPLACE_ASSET,
389
-            function (ReplaceAssetEvent $event) {
389
+            function(ReplaceAssetEvent $event) {
390 390
                 Craft::debug(
391 391
                     'Assets::EVENT_BEFORE_REPLACE_ASSET',
392 392
                     __METHOD__
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
         Event::on(
406 406
             Assets::class,
407 407
             Assets::EVENT_AFTER_REPLACE_ASSET,
408
-            function (ReplaceAssetEvent $event) {
408
+            function(ReplaceAssetEvent $event) {
409 409
                 Craft::debug(
410 410
                     'Assets::EVENT_AFTER_REPLACE_ASSET',
411 411
                     __METHOD__
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         Event::on(
429 429
             Assets::class,
430 430
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
431
-            function (ElementEvent $event) {
431
+            function(ElementEvent $event) {
432 432
                 Craft::debug(
433 433
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
434 434
                     __METHOD__
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         Event::on(
450 450
             Asset::class,
451 451
             Elements::EVENT_BEFORE_DELETE_ELEMENT,
452
-            function (ElementEvent $event) {
452
+            function(ElementEvent $event) {
453 453
                 Craft::debug(
454 454
                     'Elements::EVENT_BEFORE_DELETE_ELEMENT',
455 455
                     __METHOD__
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         Event::on(
475 475
             Fields::class,
476 476
             Fields::EVENT_AFTER_SAVE_FIELD,
477
-            function (FieldEvent $event) {
477
+            function(FieldEvent $event) {
478 478
                 Craft::debug(
479 479
                     'Fields::EVENT_AFTER_SAVE_FIELD',
480 480
                     __METHOD__
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
         Event::on(
492 492
             Plugins::class,
493 493
             Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS,
494
-            function (PluginEvent $event) {
494
+            function(PluginEvent $event) {
495 495
                 if ($event->plugin === $this) {
496 496
                     Craft::debug(
497 497
                         'Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS',
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         Event::on(
511 511
             Volumes::class,
512 512
             Volumes::EVENT_AFTER_SAVE_VOLUME,
513
-            function (VolumeEvent $event) {
513
+            function(VolumeEvent $event) {
514 514
                 Craft::debug(
515 515
                     'Volumes::EVENT_AFTER_SAVE_VOLUME',
516 516
                     __METHOD__
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         Event::on(
532 532
             Plugins::class,
533 533
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
534
-            function (PluginEvent $event) {
534
+            function(PluginEvent $event) {
535 535
                 if ($event->plugin === $this) {
536 536
                     $request = Craft::$app->getRequest();
537 537
                     if ($request->isCpRequest) {
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         Event::on(
566 566
             UrlManager::class,
567 567
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
568
-            function (RegisterUrlRulesEvent $event) {
568
+            function(RegisterUrlRulesEvent $event) {
569 569
                 Craft::debug(
570 570
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
571 571
                     __METHOD__
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
         Event::on(
589 589
             Plugins::class,
590 590
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
591
-            function () {
591
+            function() {
592 592
                 // Install these only after all other plugins have loaded
593 593
                 Event::on(
594 594
                     View::class,
595 595
                     View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
596
-                    function (RegisterTemplateRootsEvent $e) {
596
+                    function(RegisterTemplateRootsEvent $e) {
597 597
                         // Register the root directodies
598 598
                         $allImageTransformTypes = ImageOptimize::$plugin->optimize->getAllImageTransformTypes();
599 599
                         /** @var ImageTransformInterface $imageTransformType */
Please login to merge, or discard this patch.
src/services/OptimizedImages.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
                             $index->fileExists = 0;
113 113
                             $transforms->storeTransformIndexData($index);
114 114
                             $volume = $asset->getVolume();
115
-                            $transformPath = $asset->folderPath . $transforms->getTransformSubpath($asset, $index);
115
+                            $transformPath = $asset->folderPath.$transforms->getTransformSubpath($asset, $index);
116 116
                             try {
117 117
                                 $volume->deleteFile($transformPath);
118 118
                             } catch (\Throwable $exception) {
119 119
                             }
120 120
                         } catch (\Throwable $e) {
121
-                            $msg = 'Failed to update transform: ' . $e->getMessage();
121
+                            $msg = 'Failed to update transform: '.$e->getMessage();
122 122
                             Craft::error($msg, __METHOD__);
123 123
                             if (Craft::$app instanceof ConsoleApplication) {
124
-                                echo $msg . PHP_EOL;
124
+                                echo $msg.PHP_EOL;
125 125
                             }
126 126
                             // Add the error message to the stickyErrors for the model
127 127
                             $model->stickyErrors[] = $msg;
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
                     }
136 136
                 } else {
137 137
                     $canManipulate = Image::canManipulateAsImage($asset->getExtension());
138
-                    $msg = 'Could not create transform for: ' . $asset->title
139
-                        . ' - Final format: ' . $finalFormat
140
-                        . ' - Element extension: ' . $asset->getExtension()
141
-                        . ' - canManipulateAsImage: ' . $canManipulate;
138
+                    $msg = 'Could not create transform for: '.$asset->title
139
+                        . ' - Final format: '.$finalFormat
140
+                        . ' - Element extension: '.$asset->getExtension()
141
+                        . ' - canManipulateAsImage: '.$canManipulate;
142 142
                     Craft::error(
143 143
                         $msg,
144 144
                         __METHOD__
145 145
                     );
146 146
                     if (Craft::$app instanceof ConsoleApplication) {
147
-                        echo $msg . PHP_EOL;
147
+                        echo $msg.PHP_EOL;
148 148
                     }
149 149
                     if ($canManipulate) {
150 150
                         // Add the error message to the stickyErrors for the model
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
                 $this->addVariantImageToModel($asset, $model, $transform, $variant, $aspectRatio);
173 173
             } else {
174 174
                 $canManipulate = Image::canManipulateAsImage($asset->getExtension());
175
-                $msg = 'Could not create transform for: ' . $asset->title
176
-                    . ' - Final format: ' . $finalFormat
177
-                    . ' - Element extension: ' . $asset->getExtension()
178
-                    . ' - canManipulateAsImage: ' . $canManipulate;
175
+                $msg = 'Could not create transform for: '.$asset->title
176
+                    . ' - Final format: '.$finalFormat
177
+                    . ' - Element extension: '.$asset->getExtension()
178
+                    . ' - canManipulateAsImage: '.$canManipulate;
179 179
                 Craft::error(
180 180
                     $msg,
181 181
                     __METHOD__
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                                 $folder = $asset->getFolder();
215 215
                                 while ($folder !== null && !$createVariants) {
216 216
                                     if ($folder->uid === $subfolder || $folder->name === $subfolder) {
217
-                                        Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__);
217
+                                        Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__);
218 218
                                         $createVariants = true;
219 219
                                     } else {
220 220
                                         $folder = $folder->getParent();
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             if ($field->handle !== null) {
275 275
                 $asset->setFieldValue($field->handle, $field->serializeValue($model));
276 276
                 $table = $asset->getContentTable();
277
-                $column = $asset->getFieldColumnPrefix() . $field->handle;
277
+                $column = $asset->getFieldColumnPrefix().$field->handle;
278 278
                 // Special-case for Craft 3.7 or later, with the addition of a suffix to the Field content column name
279 279
                 // ref: https://github.com/craftcms/cms/issues/6922
280 280
                 if (ImageOptimize::$craft37) {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             } catch (SiteNotFoundException $e) {
342 342
                 $siteId = 0;
343 343
                 Craft::error(
344
-                    'Failed to get primary site: ' . $e->getMessage(),
344
+                    'Failed to get primary site: '.$e->getMessage(),
345 345
                     __METHOD__
346 346
                 );
347 347
             }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
     {
448 448
         Craft::beginProfile('generatePlaceholders', __METHOD__);
449 449
         Craft::info(
450
-            'generatePlaceholders for: ' . print_r($model, true),
450
+            'generatePlaceholders for: '.print_r($model, true),
451 451
             __METHOD__
452 452
         );
453 453
         $settings = ImageOptimize::$plugin->getSettings();
@@ -506,20 +506,20 @@  discard block
 block discarded – undo
506 506
         }
507 507
         $useAspectRatio = $variant['useAspectRatio'] ?? false;
508 508
         if ($useAspectRatio) {
509
-            $aspectRatio = (float)$variant['aspectRatioX'] / (float)$variant['aspectRatioY'];
509
+            $aspectRatio = (float) $variant['aspectRatioX'] / (float) $variant['aspectRatioY'];
510 510
         } else {
511
-            $aspectRatio = (float)$asset->width / (float)$asset->height;
511
+            $aspectRatio = (float) $asset->width / (float) $asset->height;
512 512
         }
513
-        $width = (int)$variant['width'] * (int)$retinaSize;
513
+        $width = (int) $variant['width'] * (int) $retinaSize;
514 514
         $transform->width = $width;
515
-        $transform->height = (int)($width / $aspectRatio);
515
+        $transform->height = (int) ($width / $aspectRatio);
516 516
         // Image quality
517
-        $quality = (int)($variant['quality'] ?? null);
517
+        $quality = (int) ($variant['quality'] ?? null);
518 518
         if (empty($quality)) {
519 519
             $quality = null;
520 520
         }
521 521
         if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') {
522
-            $quality = (int)($quality * (1.5 / (int)$retinaSize));
522
+            $quality = (int) ($quality * (1.5 / (int) $retinaSize));
523 523
         }
524 524
         $transform->quality = $quality;
525 525
         // Interlaced (progressive JPEGs or interlaced PNGs)
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             $transform
547 547
         );
548 548
         Craft::info(
549
-            'URL created: ' . print_r($url, true),
549
+            'URL created: '.print_r($url, true),
550 550
             __METHOD__
551 551
         );
552 552
         // Update the model
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                 $this->generatePlaceholders($asset, $model, $aspectRatio);
575 575
             }
576 576
             Craft::info(
577
-                'Created transforms for variant: ' . print_r($variant, true),
577
+                'Created transforms for variant: '.print_r($variant, true),
578 578
                 __METHOD__
579 579
             );
580 580
         }
Please login to merge, or discard this patch.
src/services/Placeholder.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@
 block discarded – undo
264 264
         int    $width,
265 265
         int    $height,
266 266
         int    $quality,
267
-               $position
267
+                $position
268 268
     ): string
269 269
     {
270 270
         $images = Craft::$app->getImages();
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             . "style='background:$color' "
68 68
             . "/>";
69 69
 
70
-        return $header . ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
70
+        return $header.ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
71 71
     }
72 72
 
73 73
     /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         );
89 89
         $result = '';
90 90
         $width = self::PLACEHOLDER_WIDTH;
91
-        $height = (int)($width / $aspectRatio);
91
+        $height = (int) ($width / $aspectRatio);
92 92
         $placeholderPath = $this->createImageFromPath($tempPath, $width, $height, self::PLACEHOLDER_QUALITY, $position);
93 93
         if (!empty($placeholderPath)) {
94 94
             $result = base64_encode(file_get_contents($placeholderPath));
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     {
111 111
         Craft::beginProfile('generateColorPalette', __METHOD__);
112 112
         Craft::info(
113
-            'Generating color palette for: ' . $tempPath,
113
+            'Generating color palette for: '.$tempPath,
114 114
             __METHOD__
115 115
         );
116 116
         $colorPalette = [];
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             $lightness /= $colorCount;
157 157
         }
158 158
 
159
-        return $lightness === null ? $lightness : (int)$lightness;
159
+        return $lightness === null ? $lightness : (int) $lightness;
160 160
     }
161 161
 
162 162
     /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             __METHOD__
222 222
         );
223 223
         $width = self::TEMP_PLACEHOLDER_WIDTH;
224
-        $height = (int)($width / $aspectRatio);
224
+        $height = (int) ($width / $aspectRatio);
225 225
         $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position);
226 226
         Craft::endProfile('createTempPlaceholderImage', __METHOD__);
227 227
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             }
279 279
         } catch (\Throwable $e) {
280 280
             Craft::error(
281
-                'Error creating temporary image: ' . $e->getMessage(),
281
+                'Error creating temporary image: '.$e->getMessage(),
282 282
                 __METHOD__
283 283
             );
284 284
 
@@ -299,14 +299,14 @@  discard block
 block discarded – undo
299 299
         }
300 300
 
301 301
         // Save the image out to a temp file, then return its contents
302
-        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true) . '.' . 'jpg';
303
-        $tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename;
302
+        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true).'.'.'jpg';
303
+        $tempPath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$tempFilename;
304 304
         clearstatcache(true, $tempPath);
305 305
         try {
306 306
             $image->saveAs($tempPath);
307 307
         } catch (\Throwable $e) {
308 308
             Craft::error(
309
-                'Error saving temporary image: ' . $e->getMessage(),
309
+                'Error saving temporary image: '.$e->getMessage(),
310 310
                 __METHOD__
311 311
             );
312 312
         }
Please login to merge, or discard this patch.