Passed
Push — develop ( ade286...bb793a )
by Andrew
22:28 queued 17:49
created
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/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.
src/variables/ImageOptimizeVariable.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@
 block discarded – undo
79 79
      */
80 80
     public function createOptimizedImages(
81 81
         Asset $asset,
82
-              $variants = null,
83
-              $generatePlaceholders = false
82
+                $variants = null,
83
+                $generatePlaceholders = false
84 84
     )
85 85
     {
86 86
         // Override our settings for lengthy operations, since we're doing this via Twig
Please login to merge, or discard this patch.
src/console/controllers/OptimizeController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function actionCreate($volumeHandle = null)
58 58
     {
59
-        echo 'Creating optimized image variants' . PHP_EOL;
59
+        echo 'Creating optimized image variants'.PHP_EOL;
60 60
         if ($this->force) {
61
-            echo 'Forcing optimized image variants creation via --force' . PHP_EOL;
61
+            echo 'Forcing optimized image variants creation via --force'.PHP_EOL;
62 62
         }
63 63
 
64 64
         $fieldId = null;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 /** @var Volume $volume */
80 80
                 ImageOptimize::$plugin->optimizedImages->resaveVolumeAssets($volume, $fieldId, $this->force);
81 81
             } else {
82
-                echo 'Unknown Asset Volume handle: ' . $volumeHandle . PHP_EOL;
82
+                echo 'Unknown Asset Volume handle: '.$volumeHandle.PHP_EOL;
83 83
             }
84 84
         }
85 85
         $this->runCraftQueue();
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function actionCreateAsset($id = null)
94 94
     {
95
-        echo 'Creating optimized image variants' . PHP_EOL;
95
+        echo 'Creating optimized image variants'.PHP_EOL;
96 96
 
97 97
         if ($id === null) {
98
-            echo 'No Asset ID specified' . PHP_EOL;
98
+            echo 'No Asset ID specified'.PHP_EOL;
99 99
         } else {
100 100
             // Re-save a single Asset ID
101 101
             ImageOptimize::$plugin->optimizedImages->resaveAsset($id, $this->force);
Please login to merge, or discard this patch.
src/jobs/ResaveOptimizedImages.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             Craft::configure($query, $this->criteria);
82 82
         }
83 83
         if (Craft::$app instanceof ConsoleApplication) {
84
-            echo $this->description . PHP_EOL;
84
+            echo $this->description.PHP_EOL;
85 85
         }
86 86
         // Use craft\db\Paginator to paginate the results so we don't exceed any memory limits
87 87
         // See batch() and each() discussion here: https://github.com/yiisoft/yii2/issues/8420
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         while ($currentElement < $totalElements) {
96 96
             $elements = $paginator->getPageResults();
97 97
             if (Craft::$app instanceof ConsoleApplication) {
98
-                echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages()
99
-                    . ' - assets: ' . $paginator->getTotalResults()
98
+                echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages()
99
+                    . ' - assets: '.$paginator->getTotalResults()
100 100
                     . PHP_EOL;
101 101
             }
102 102
             /** @var ElementInterface $element */
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                         if ($field instanceof OptimizedImagesField && $element instanceof Asset) {
112 112
                             if ($this->fieldId === null || $field->id == $this->fieldId) {
113 113
                                 if (Craft::$app instanceof ConsoleApplication) {
114
-                                    echo $currentElement . '/' . $totalElements
115
-                                        . ' - processing asset: ' . $element->title
116
-                                        . ' from field: ' . $field->name . PHP_EOL;
114
+                                    echo $currentElement.'/'.$totalElements
115
+                                        . ' - processing asset: '.$element->title
116
+                                        . ' from field: '.$field->name.PHP_EOL;
117 117
                                 }
118 118
                                 try {
119 119
                                     ImageOptimize::$plugin->optimizedImages->updateOptimizedImageFieldData($field, $element, $this->force);
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
                                         echo '[error]: '
124 124
                                             . $e->getMessage()
125 125
                                             . ' while processing '
126
-                                            . $currentElement . '/' . $totalElements
127
-                                            . ' - processing asset: ' . $element->title
128
-                                            . ' from field: ' . $field->name . PHP_EOL;
126
+                                            . $currentElement.'/'.$totalElements
127
+                                            . ' - processing asset: '.$element->title
128
+                                            . ' from field: '.$field->name.PHP_EOL;
129 129
                                     }
130 130
                                 }
131 131
                             }
Please login to merge, or discard this patch.
src/models/OptimizedImage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
             return $this->defaultPlaceholderImage();
549 549
         }
550 550
 
551
-        return Template::raw($header . rawurlencode($content));
551
+        return Template::raw($header.rawurlencode($content));
552 552
     }
553 553
 
554 554
     /**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
      */
559 559
     public function getPlaceholderImage(): string
560 560
     {
561
-        return (string)$this->placeholderImage();
561
+        return (string) $this->placeholderImage();
562 562
     }
563 563
 
564 564
     /**
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
      */
596 596
     public function getPlaceholderBox(string $color = null): string
597 597
     {
598
-        return (string)$this->placeholderBox($color);
598
+        return (string) $this->placeholderBox($color);
599 599
     }
600 600
 
601 601
     /**
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
             return $this->defaultPlaceholderImage();
627 627
         }
628 628
 
629
-        return Template::raw($header . $content);
629
+        return Template::raw($header.$content);
630 630
     }
631 631
 
632 632
     /**
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
      */
637 637
     public function getPlaceholderSilhouette(): string
638 638
     {
639
-        return (string)$this->placeholderSilhouette();
639
+        return (string) $this->placeholderSilhouette();
640 640
     }
641 641
 
642 642
     /**
@@ -752,16 +752,16 @@  discard block
 block discarded – undo
752 752
         foreach ($array as $key => $value) {
753 753
             if ($dpr) {
754 754
                 $descriptor = '1x';
755
-                if (!empty($array[(int)$key / 2])) {
755
+                if (!empty($array[(int) $key / 2])) {
756 756
                     $descriptor = '2x';
757 757
                 }
758
-                if (!empty($array[(int)$key / 3])) {
758
+                if (!empty($array[(int) $key / 3])) {
759 759
                     $descriptor = '3x';
760 760
                 }
761 761
             } else {
762
-                $descriptor = $key . 'w';
762
+                $descriptor = $key.'w';
763 763
             }
764
-            $srcset .= $value . ' ' . $descriptor . ', ';
764
+            $srcset .= $value.' '.$descriptor.', ';
765 765
         }
766 766
         $srcset = rtrim($srcset, ', ');
767 767
 
@@ -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/ImageTransform.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             if (ImageOptimize::$craft31) {
113 113
                 $subfolder = Craft::parseEnv($subfolder);
114 114
             }
115
-            return rtrim($subfolder, '/') . '/' . $assetPath;
115
+            return rtrim($subfolder, '/').'/'.$assetPath;
116 116
         }
117 117
 
118 118
         return $assetPath;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $path = $this->decomposeUrl($pathOrUrl);
150 150
         $path_parts = pathinfo($path['path']);
151
-        $new_path = ($path_parts['filename'] ?? '') . '.' . ($path_parts['extension'] ?? '') . $extension;
151
+        $new_path = ($path_parts['filename'] ?? '').'.'.($path_parts['extension'] ?? '').$extension;
152 152
         if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== '.') {
153 153
             $dirname = $path_parts['dirname'];
154 154
             $dirname = $dirname === '/' ? '' : $dirname;
155
-            $new_path = $dirname . DIRECTORY_SEPARATOR . $new_path;
155
+            $new_path = $dirname.DIRECTORY_SEPARATOR.$new_path;
156 156
             $new_path = preg_replace('/([^:])(\/{2,})/', '$1/', $new_path);
157 157
         }
158
-        $output = $path['prefix'] . $new_path . $path['suffix'];
158
+        $output = $path['prefix'].$new_path.$path['suffix'];
159 159
 
160 160
         return $output;
161 161
     }
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 
177 177
         if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) {
178 178
             $url_parts = parse_url($pathOrUrl);
179
-            $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host'];
179
+            $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host'];
180 180
             if (!empty($url_parts['port'])) {
181
-                $result['prefix'] .= ':' . $url_parts['port'];
181
+                $result['prefix'] .= ':'.$url_parts['port'];
182 182
             }
183 183
             $result['path'] = $url_parts['path'];
184 184
             $result['suffix'] = '';
185
-            $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query'];
186
-            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment'];
185
+            $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query'];
186
+            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment'];
187 187
         } else {
188 188
             $result['prefix'] = '';
189 189
             $result['path'] = $pathOrUrl;
Please login to merge, or discard this patch.