Passed
Push — v1 ( fd8bb1...1615e8 )
by Andrew
11:30 queued 04:27
created
src/services/Placeholder.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             . "style='background:$color' "
70 70
             . "/>";
71 71
 
72
-        return $header . ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
72
+        return $header.ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
73 73
     }
74 74
 
75 75
     /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         );
91 91
         $result = '';
92 92
         $width = self::PLACEHOLDER_WIDTH;
93
-        $height = (int)($width / $aspectRatio);
93
+        $height = (int) ($width / $aspectRatio);
94 94
         $placeholderPath = $this->createImageFromPath($tempPath, $width, $height, self::PLACEHOLDER_QUALITY, $position);
95 95
         if (!empty($placeholderPath)) {
96 96
             $result = base64_encode(file_get_contents($placeholderPath));
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         Craft::beginProfile('generateColorPalette', __METHOD__);
114 114
         Craft::info(
115
-            'Generating color palette for: ' . $tempPath,
115
+            'Generating color palette for: '.$tempPath,
116 116
             __METHOD__
117 117
         );
118 118
         $colorPalette = [];
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $lightness /= $colorCount;
159 159
         }
160 160
 
161
-        return $lightness === null ? $lightness : (int)$lightness;
161
+        return $lightness === null ? $lightness : (int) $lightness;
162 162
     }
163 163
 
164 164
     /**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             __METHOD__
225 225
         );
226 226
         $width = self::TEMP_PLACEHOLDER_WIDTH;
227
-        $height = (int)($width / $aspectRatio);
227
+        $height = (int) ($width / $aspectRatio);
228 228
         $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position);
229 229
         Craft::endProfile('createTempPlaceholderImage', __METHOD__);
230 230
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             }
281 281
         } catch (Throwable $e) {
282 282
             Craft::error(
283
-                'Error creating temporary image: ' . $e->getMessage(),
283
+                'Error creating temporary image: '.$e->getMessage(),
284 284
                 __METHOD__
285 285
             );
286 286
 
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
         }
304 304
 
305 305
         // Save the image out to a temp file, then return its contents
306
-        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true) . '.' . 'jpg';
307
-        $tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename;
306
+        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true).'.'.'jpg';
307
+        $tempPath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$tempFilename;
308 308
         clearstatcache(true, $tempPath);
309 309
         try {
310 310
             $image->saveAs($tempPath);
311 311
         } catch (Throwable $e) {
312 312
             Craft::error(
313
-                'Error saving temporary image: ' . $e->getMessage(),
313
+                'Error saving temporary image: '.$e->getMessage(),
314 314
                 __METHOD__
315 315
             );
316 316
         }
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
         int    $width,
268 268
         int    $height,
269 269
         int    $quality,
270
-               $position
270
+                $position
271 271
     ): string {
272 272
         $images = Craft::$app->getImages();
273 273
         $pathParts = pathinfo($filePath);
Please login to merge, or discard this patch.
src/services/OptimizedImages.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 // Only try the transform if it's possible
105 105
                 if (Image::canManipulateAsImage($finalFormat)
106 106
                     && Image::canManipulateAsImage($asset->getExtension())
107
-                    && (int)$asset->height > 0) {
107
+                    && (int) $asset->height > 0) {
108 108
                     // Create the transform based on the variant
109 109
                     /** @var AssetTransform $transform */
110 110
                     list($transform, $aspectRatio) = $this->getTransformFromVariant($asset, $variant, $retinaSize);
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
                             $index->fileExists = false;
117 117
                             $transforms->storeTransformIndexData($index);
118 118
                             $volume = $asset->getVolume();
119
-                            $transformPath = $asset->folderPath . $transforms->getTransformSubpath($asset, $index);
119
+                            $transformPath = $asset->folderPath.$transforms->getTransformSubpath($asset, $index);
120 120
                             try {
121 121
                                 $volume->deleteFile($transformPath);
122 122
                             } catch (Throwable $exception) {
123 123
                             }
124 124
                         } catch (Throwable $e) {
125
-                            $msg = 'Failed to update transform: ' . $e->getMessage();
125
+                            $msg = 'Failed to update transform: '.$e->getMessage();
126 126
                             Craft::error($msg, __METHOD__);
127 127
                             if (Craft::$app instanceof ConsoleApplication) {
128
-                                echo $msg . PHP_EOL;
128
+                                echo $msg.PHP_EOL;
129 129
                             }
130 130
                             // Add the error message to the stickyErrors for the model
131 131
                             $model->stickyErrors[] = $msg;
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                     }
140 140
                 } else {
141 141
                     $canManipulate = Image::canManipulateAsImage($asset->getExtension());
142
-                    $msg = 'Could not create transform for: ' . $asset->title
143
-                        . ' - Final format: ' . $finalFormat
144
-                        . ' - Element extension: ' . $asset->getExtension()
145
-                        . ' - canManipulateAsImage: ' . $canManipulate;
142
+                    $msg = 'Could not create transform for: '.$asset->title
143
+                        . ' - Final format: '.$finalFormat
144
+                        . ' - Element extension: '.$asset->getExtension()
145
+                        . ' - canManipulateAsImage: '.$canManipulate;
146 146
                     Craft::error(
147 147
                         $msg,
148 148
                         __METHOD__
149 149
                     );
150 150
                     if (Craft::$app instanceof ConsoleApplication) {
151
-                        echo $msg . PHP_EOL;
151
+                        echo $msg.PHP_EOL;
152 152
                     }
153 153
                     if ($canManipulate) {
154 154
                         // Add the error message to the stickyErrors for the model
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         if (empty($model->optimizedImageUrls)) {
163 163
             $finalFormat = $asset->getExtension();
164 164
             if (Image::canManipulateAsImage($finalFormat)
165
-                && (int)$asset->height > 0) {
165
+                && (int) $asset->height > 0) {
166 166
                 $variant = [
167 167
                     'width' => $asset->width,
168 168
                     'useAspectRatio' => false,
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
                 $this->addVariantImageToModel($asset, $model, $transform, $variant, $aspectRatio);
176 176
             } else {
177 177
                 $canManipulate = Image::canManipulateAsImage($asset->getExtension());
178
-                $msg = 'Could not create transform for: ' . $asset->title
179
-                    . ' - Final format: ' . $finalFormat
180
-                    . ' - Element extension: ' . $asset->getExtension()
181
-                    . ' - canManipulateAsImage: ' . $canManipulate;
178
+                $msg = 'Could not create transform for: '.$asset->title
179
+                    . ' - Final format: '.$finalFormat
180
+                    . ' - Element extension: '.$asset->getExtension()
181
+                    . ' - canManipulateAsImage: '.$canManipulate;
182 182
                 Craft::error(
183 183
                     $msg,
184 184
                     __METHOD__
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                                 $folder = $asset->getFolder();
218 218
                                 while ($folder !== null && !$createVariants) {
219 219
                                     if ($folder->uid === $subfolder || $folder->name === $subfolder) {
220
-                                        Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__);
220
+                                        Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__);
221 221
                                         $createVariants = true;
222 222
                                     } else {
223 223
                                         $folder = $folder->getParent();
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             if ($field->handle !== null) {
278 278
                 $asset->setFieldValue($field->handle, $field->serializeValue($model));
279 279
                 $table = $asset->getContentTable();
280
-                $column = $asset->getFieldColumnPrefix() . $field->handle;
280
+                $column = $asset->getFieldColumnPrefix().$field->handle;
281 281
                 // Special-case for Craft 3.7 or later, with the addition of a suffix to the Field content column name
282 282
                 // ref: https://github.com/craftcms/cms/issues/6922
283 283
                 if (ImageOptimize::$craft37) {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
             } catch (SiteNotFoundException $e) {
345 345
                 $siteId = 0;
346 346
                 Craft::error(
347
-                    'Failed to get primary site: ' . $e->getMessage(),
347
+                    'Failed to get primary site: '.$e->getMessage(),
348 348
                     __METHOD__
349 349
                 );
350 350
             }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
     {
451 451
         Craft::beginProfile('generatePlaceholders', __METHOD__);
452 452
         Craft::info(
453
-            'generatePlaceholders for: ' . print_r($model, true),
453
+            'generatePlaceholders for: '.print_r($model, true),
454 454
             __METHOD__
455 455
         );
456 456
         /** @var Settings $settings */
@@ -511,20 +511,20 @@  discard block
 block discarded – undo
511 511
         }
512 512
         $useAspectRatio = $variant['useAspectRatio'] ?? false;
513 513
         if ($useAspectRatio) {
514
-            $aspectRatio = (float)$variant['aspectRatioX'] / (float)$variant['aspectRatioY'];
514
+            $aspectRatio = (float) $variant['aspectRatioX'] / (float) $variant['aspectRatioY'];
515 515
         } else {
516
-            $aspectRatio = (float)$asset->width / (float)$asset->height;
516
+            $aspectRatio = (float) $asset->width / (float) $asset->height;
517 517
         }
518
-        $width = (int)$variant['width'] * (int)$retinaSize;
518
+        $width = (int) $variant['width'] * (int) $retinaSize;
519 519
         $transform->width = $width;
520
-        $transform->height = (int)($width / $aspectRatio);
520
+        $transform->height = (int) ($width / $aspectRatio);
521 521
         // Image quality
522
-        $quality = (int)($variant['quality'] ?? null);
522
+        $quality = (int) ($variant['quality'] ?? null);
523 523
         if (empty($quality)) {
524 524
             $quality = null;
525 525
         }
526 526
         if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') {
527
-            $quality = (int)($quality * (1.5 / (int)$retinaSize));
527
+            $quality = (int) ($quality * (1.5 / (int) $retinaSize));
528 528
         }
529 529
         $transform->quality = $quality;
530 530
         // Interlaced (progressive JPEGs or interlaced PNGs)
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
             $transform
552 552
         );
553 553
         Craft::info(
554
-            'URL created: ' . print_r($url, true),
554
+            'URL created: '.print_r($url, true),
555 555
             __METHOD__
556 556
         );
557 557
         // Update the model
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
                 $this->generatePlaceholders($asset, $model, $aspectRatio);
580 580
             }
581 581
             Craft::info(
582
-                'Created transforms for variant: ' . print_r($variant, true),
582
+                'Created transforms for variant: '.print_r($variant, true),
583 583
                 __METHOD__
584 584
             );
585 585
         }
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.
src/gql/types/generators/OptimizedImagesGenerator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -279,6 +279,6 @@
 block discarded – undo
279 279
     public static function getName($context = null): string
280 280
     {
281 281
         /** @var OptimizedImages $context */
282
-        return $context->handle . '_OptimizedImages';
282
+        return $context->handle.'_OptimizedImages';
283 283
     }
284 284
 }
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
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
         array  $params = [],
64 64
         string $minifier = null
65 65
     ): string {
66
-        $template = 'image-optimize/' . $templatePath;
66
+        $template = 'image-optimize/'.$templatePath;
67 67
         $oldMode = Craft::$app->view->getTemplateMode();
68 68
         // Look for the template on the frontend first
69 69
         try {
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
@@ -78,8 +78,8 @@
 block discarded – undo
78 78
      */
79 79
     public function createOptimizedImages(
80 80
         Asset $asset,
81
-              $variants = null,
82
-              $generatePlaceholders = false
81
+                $variants = null,
82
+                $generatePlaceholders = false
83 83
     ) {
84 84
         // Override our settings for lengthy operations, since we're doing this via Twig
85 85
         ImageOptimize::$generatePlaceholders = $generatePlaceholders;
Please login to merge, or discard this patch.
src/models/BaseImageTag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         // Set the class and loading attributes
33 33
         if (isset($attrs['class'])) {
34
-            $attrs['class'] = trim($attrs['class'] . ' lazyload');
34
+            $attrs['class'] = trim($attrs['class'].' lazyload');
35 35
         }
36 36
         // Set the style on this element to be the placeholder image as the background-image
37 37
         if (isset($attrs['style']) && !empty($attrs['src'])) {
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             }
41 41
             // Don't add the background placeholder if it is set to 'none'
42 42
             if ($placeHolder !== 'none') {
43
-                $attrs['style']['background-image'] = 'url(' . $this->getLazyLoadSrc($placeHolder) . ')';
43
+                $attrs['style']['background-image'] = 'url('.$this->getLazyLoadSrc($placeHolder).')';
44 44
                 $attrs['style']['background-size'] = 'cover';
45 45
             }
46 46
         }
Please login to merge, or discard this patch.