Passed
Pull Request — develop-v4 (#380)
by
unknown
17:45
created
src/models/OptimizedImage.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
             return $this->defaultPlaceholderImage();
548 548
         }
549 549
 
550
-        return Template::raw($header . rawurlencode($content));
550
+        return Template::raw($header.rawurlencode($content));
551 551
     }
552 552
 
553 553
     /**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             return $this->defaultPlaceholderImage();
626 626
         }
627 627
 
628
-        return Template::raw($header . $content);
628
+        return Template::raw($header.$content);
629 629
     }
630 630
 
631 631
     /**
@@ -753,16 +753,16 @@  discard block
 block discarded – undo
753 753
         foreach ($array as $key => $value) {
754 754
             if ($dpr) {
755 755
                 $descriptor = '1x';
756
-                if (!empty($array[(int)$key / 2])) {
756
+                if (!empty($array[(int) $key / 2])) {
757 757
                     $descriptor = '2x';
758 758
                 }
759
-                if (!empty($array[(int)$key / 3])) {
759
+                if (!empty($array[(int) $key / 3])) {
760 760
                     $descriptor = '3x';
761 761
                 }
762 762
             } else {
763
-                $descriptor = $key . 'w';
763
+                $descriptor = $key.'w';
764 764
             }
765
-            $srcset .= $value . ' ' . $descriptor . ', ';
765
+            $srcset .= $value.' '.$descriptor.', ';
766 766
         }
767 767
 
768 768
         return rtrim($srcset, ', ');
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
     {
797 797
         // Set the class and loading attributes
798 798
         if (isset($attrs['class'])) {
799
-            $attrs['class'] = trim($attrs['class'] . ' lazyload');
799
+            $attrs['class'] = trim($attrs['class'].' lazyload');
800 800
         }
801 801
         // Set the style on this element to be the placeholder image as the background-image
802 802
         if (isset($attrs['style']) && !empty($attrs['src'])) {
803 803
             $attrs['style'] = trim(
804
-                $attrs['style'] .
805
-                'background-image:url(' . $this->getLazyLoadSrc($placeHolder) . '); background-size: cover;'
804
+                $attrs['style'].
805
+                'background-image:url('.$this->getLazyLoadSrc($placeHolder).'); background-size: cover;'
806 806
             );
807 807
         }
808 808
         // Handle attributes that lazy  and lazySizesFallback have in common
Please login to merge, or discard this patch.
src/imagetransforms/ImageTransformInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return string|null
47 47
      */
48
-    public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string;
48
+    public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string;
49 49
 
50 50
     /**
51 51
      * Return a URL to the webp version of the transformed image
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      *
57 57
      * @return ?string
58 58
      */
59
-    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string;
59
+    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string;
60 60
 
61 61
     /**
62 62
      * Return the URL that should be used to purge the Asset
Please login to merge, or discard this patch.
src/imagetransforms/ImageTransform.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * @inheritdoc
66 66
      */
67
-    public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
67
+    public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
68 68
     {
69 69
         return null;
70 70
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @inheritdoc
74 74
      */
75
-    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
75
+    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
76 76
     {
77 77
         return $url;
78 78
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if ($volume->getFs()->subfolder ?? null) {
107 107
             $subfolder = $volume->getFs()->subfolder;
108 108
             $subfolder = Craft::parseEnv($subfolder);
109
-            return rtrim($subfolder, '/') . '/' . $assetPath;
109
+            return rtrim($subfolder, '/').'/'.$assetPath;
110 110
         }
111 111
 
112 112
         return $assetPath;
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $path = $this->decomposeUrl($pathOrUrl);
145 145
         $path_parts = pathinfo($path['path']);
146
-        $new_path = ($path_parts['filename'] ?? '') . '.' . ($path_parts['extension'] ?? '') . $extension;
146
+        $new_path = ($path_parts['filename'] ?? '').'.'.($path_parts['extension'] ?? '').$extension;
147 147
         if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== '.') {
148 148
             $dirname = $path_parts['dirname'];
149 149
             $dirname = $dirname === '/' ? '' : $dirname;
150
-            $new_path = $dirname . DIRECTORY_SEPARATOR . $new_path;
150
+            $new_path = $dirname.DIRECTORY_SEPARATOR.$new_path;
151 151
             $new_path = preg_replace('/([^:])(\/{2,})/', '$1/', $new_path);
152 152
         }
153 153
 
154
-        return $path['prefix'] . $new_path . $path['suffix'];
154
+        return $path['prefix'].$new_path.$path['suffix'];
155 155
     }
156 156
 
157 157
     // Protected Methods
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 
171 171
         if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) {
172 172
             $url_parts = parse_url($pathOrUrl);
173
-            $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host'];
173
+            $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host'];
174 174
             if (!empty($url_parts['port'])) {
175
-                $result['prefix'] .= ':' . $url_parts['port'];
175
+                $result['prefix'] .= ':'.$url_parts['port'];
176 176
             }
177 177
             $result['path'] = $url_parts['path'];
178 178
             $result['suffix'] = '';
179
-            $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query'];
180
-            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment'];
179
+            $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query'];
180
+            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment'];
181 181
         } else {
182 182
             $result['prefix'] = '';
183 183
             $result['path'] = $pathOrUrl;
Please login to merge, or discard this patch.
src/imagetransforms/CraftImageTransform.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @inheritDoc
59 59
      */
60
-    public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
60
+    public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
61 61
     {
62 62
         // Generate the URLs to the optimized images
63 63
         $oldValue = Craft::$app->getConfig()->getGeneral()->generateTransformsBeforePageLoad;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     /**
75 75
      * @inheritDoc
76 76
      */
77
-    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
77
+    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
78 78
     {
79 79
         return $this->appendExtension($url, '.webp');
80 80
     }
Please login to merge, or discard this patch.
src/helpers/Color.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
         }
38 38
 
39 39
         if (strlen($htmlCode) === 3) {
40
-            $htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
40
+            $htmlCode = $htmlCode[0].$htmlCode[0].$htmlCode[1].$htmlCode[1].$htmlCode[2].$htmlCode[2];
41 41
         }
42 42
 
43
-        $r = hexdec($htmlCode[0] . $htmlCode[1]);
44
-        $g = hexdec($htmlCode[2] . $htmlCode[3]);
45
-        $b = hexdec($htmlCode[4] . $htmlCode[5]);
43
+        $r = hexdec($htmlCode[0].$htmlCode[1]);
44
+        $g = hexdec($htmlCode[2].$htmlCode[3]);
45
+        $b = hexdec($htmlCode[4].$htmlCode[5]);
46 46
 
47 47
         return ['r' => $r, 'g' => $g, 'b' => $b];
48 48
     }
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public static function RGBToHSL(array $rgb): array
58 58
     {
59
-        $r = ((float)$rgb['r']) / 255.0;
60
-        $g = ((float)$rgb['g']) / 255.0;
61
-        $b = ((float)$rgb['b']) / 255.0;
59
+        $r = ((float) $rgb['r']) / 255.0;
60
+        $g = ((float) $rgb['g']) / 255.0;
61
+        $b = ((float) $rgb['b']) / 255.0;
62 62
 
63 63
         $maxC = max($r, $g, $b);
64 64
         $minC = min($r, $g, $b);
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
             $h /= 6.0;
87 87
         }
88 88
 
89
-        $h = (int)round(360.0 * $h);
90
-        $s = (int)round(100.0 * $s);
91
-        $l = (int)round(100.0 * $l);
89
+        $h = (int) round(360.0 * $h);
90
+        $s = (int) round(100.0 * $s);
91
+        $l = (int) round(100.0 * $l);
92 92
 
93 93
         return ['h' => $h, 's' => $s, 'l' => $l];
94 94
     }
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
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
         // so we can't extract it from the passed in $config
42 42
         $majorVersion = '4';
43 43
         // Dev server container name & port are based on the major version of this plugin
44
-        $devPort = 3000 + (int)$majorVersion;
45
-        $versionName = 'v' . $majorVersion;
44
+        $devPort = 3000 + (int) $majorVersion;
45
+        $versionName = 'v'.$majorVersion;
46 46
         return [
47 47
             'components' => [
48 48
                 'optimize' => OptimizeService::class,
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
                     'assetClass' => ImageOptimizeAsset::class,
54 54
                     'checkDevServer' => true,
55 55
                     'class' => VitePluginService::class,
56
-                    'devServerInternal' => 'http://craft-imageoptimize-' . $versionName . '-buildchain-dev:' . $devPort,
57
-                    'devServerPublic' => 'http://localhost:' . $devPort,
56
+                    'devServerInternal' => 'http://craft-imageoptimize-'.$versionName.'-buildchain-dev:'.$devPort,
57
+                    'devServerPublic' => 'http://localhost:'.$devPort,
58 58
                     'errorEntry' => 'src/js/ImageOptimize.js',
59 59
                     'useDevServer' => true,
60 60
                 ],
Please login to merge, or discard this patch.
src/ImageOptimize.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     /**
138 138
      * @inheritdoc
139 139
      */
140
-    public function getSettingsResponse(): TemplateResponseBehavior|Response
140
+    public function getSettingsResponse(): TemplateResponseBehavior | Response
141 141
     {
142 142
         $view = Craft::$app->getView();
143 143
         $namespace = $view->getNamespace();
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         Event::on(
237 237
             CraftVariable::class,
238 238
             CraftVariable::EVENT_INIT,
239
-            function (Event $event) {
239
+            function(Event $event) {
240 240
                 /** @var CraftVariable $variable */
241 241
                 $variable = $event->sender;
242 242
                 $variable->set('imageOptimize', [
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         Event::on(
251 251
             Fields::class,
252 252
             Fields::EVENT_REGISTER_FIELD_TYPES,
253
-            static function (RegisterComponentTypesEvent $event) {
253
+            static function(RegisterComponentTypesEvent $event) {
254 254
                 Craft::debug(
255 255
                     'Fields::EVENT_REGISTER_FIELD_TYPES',
256 256
                     __METHOD__
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             Event::on(
265 265
                 Utilities::class,
266 266
                 Utilities::EVENT_REGISTER_UTILITY_TYPES,
267
-                static function (RegisterComponentTypesEvent $event) {
267
+                static function(RegisterComponentTypesEvent $event) {
268 268
                     $event->types[] = ImageOptimizeUtility::class;
269 269
                 }
270 270
             );
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         Event::on(
310 310
             Asset::class,
311 311
             $eventName,
312
-            static function (DefineAssetUrlEvent $event): void {
312
+            static function(DefineAssetUrlEvent $event): void {
313 313
                 Craft::debug(
314 314
                     'Asset::EVENT_DEFINE_URL',
315 315
                     __METHOD__
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         Event::on(
326 326
             Assets::class,
327 327
             Assets::EVENT_DEFINE_THUMB_URL,
328
-            static function (DefineAssetThumbUrlEvent $event): void {
328
+            static function(DefineAssetThumbUrlEvent $event): void {
329 329
                 Craft::debug(
330 330
                     'Assets::EVENT_DEFINE_THUMB_URL',
331 331
                     __METHOD__
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         Event::on(
342 342
             ImageTransformer::class,
343 343
             ImageTransformer::EVENT_TRANSFORM_IMAGE,
344
-            static function (ImageTransformerOperationEvent $event): void {
344
+            static function(ImageTransformerOperationEvent $event): void {
345 345
                 Craft::debug(
346 346
                     'ImageTransformer::EVENT_TRANSFORM_IMAGE',
347 347
                     __METHOD__
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
         Event::on(
361 361
             ImageTransformer::class,
362 362
             ImageTransformer::EVENT_DELETE_TRANSFORMED_IMAGE,
363
-            static function (ImageTransformerOperationEvent $event): void {
363
+            static function(ImageTransformerOperationEvent $event): void {
364 364
                 Craft::debug(
365 365
                     'ImageTransformer::EVENT_DELETE_TRANSFORMED_IMAGE',
366 366
                     __METHOD__
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         Event::on(
377 377
             Assets::class,
378 378
             Assets::EVENT_BEFORE_REPLACE_ASSET,
379
-            static function (ReplaceAssetEvent $event) {
379
+            static function(ReplaceAssetEvent $event) {
380 380
                 Craft::debug(
381 381
                     'Assets::EVENT_BEFORE_REPLACE_ASSET',
382 382
                     __METHOD__
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
         Event::on(
395 395
             Assets::class,
396 396
             Assets::EVENT_AFTER_REPLACE_ASSET,
397
-            static function (ReplaceAssetEvent $event) {
397
+            static function(ReplaceAssetEvent $event) {
398 398
                 Craft::debug(
399 399
                     'Assets::EVENT_AFTER_REPLACE_ASSET',
400 400
                     __METHOD__
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
         Event::on(
417 417
             Assets::class,
418 418
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
419
-            static function (ElementEvent $event) {
419
+            static function(ElementEvent $event) {
420 420
                 Craft::debug(
421 421
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
422 422
                     __METHOD__
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         Event::on(
438 438
             Asset::class,
439 439
             Elements::EVENT_BEFORE_DELETE_ELEMENT,
440
-            static function (ElementEvent $event) {
440
+            static function(ElementEvent $event) {
441 441
                 Craft::debug(
442 442
                     'Elements::EVENT_BEFORE_DELETE_ELEMENT',
443 443
                     __METHOD__
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         Event::on(
463 463
             Fields::class,
464 464
             Fields::EVENT_AFTER_SAVE_FIELD,
465
-            function (FieldEvent $event) {
465
+            function(FieldEvent $event) {
466 466
                 Craft::debug(
467 467
                     'Fields::EVENT_AFTER_SAVE_FIELD',
468 468
                     __METHOD__
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
         Event::on(
481 481
             Plugins::class,
482 482
             Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS,
483
-            function (PluginEvent $event) {
483
+            function(PluginEvent $event) {
484 484
                 if ($event->plugin === $this) {
485 485
                     Craft::debug(
486 486
                         'Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS',
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
         Event::on(
501 501
             Volumes::class,
502 502
             Volumes::EVENT_AFTER_SAVE_VOLUME,
503
-            function (VolumeEvent $event) {
503
+            function(VolumeEvent $event) {
504 504
                 Craft::debug(
505 505
                     'Volumes::EVENT_AFTER_SAVE_VOLUME',
506 506
                     __METHOD__
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         Event::on(
520 520
             Plugins::class,
521 521
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
522
-            function (PluginEvent $event) {
522
+            function(PluginEvent $event) {
523 523
                 if ($event->plugin === $this) {
524 524
                     $request = Craft::$app->getRequest();
525 525
                     if ($request->isCpRequest) {
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         Event::on(
540 540
             UrlManager::class,
541 541
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
542
-            function (RegisterUrlRulesEvent $event) {
542
+            function(RegisterUrlRulesEvent $event) {
543 543
                 Craft::debug(
544 544
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
545 545
                     __METHOD__
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
         Event::on(
563 563
             Plugins::class,
564 564
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
565
-            static function () {
565
+            static function() {
566 566
                 // Install these only after all other plugins have loaded
567 567
                 Event::on(
568 568
                     View::class,
569 569
                     View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
570
-                    static function (RegisterTemplateRootsEvent $e) {
570
+                    static function(RegisterTemplateRootsEvent $e) {
571 571
                         // Register the root directodies
572 572
                         $allImageTransformTypes = ImageOptimize::$plugin->optimize->getAllImageTransformTypes();
573 573
                         /** @var ImageTransformInterface $imageTransformType */
Please login to merge, or discard this patch.