Passed
Push — develop ( 67c897...6e7bf1 )
by Andrew
06:31
created
src/console/controllers/OptimizeController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function actionCreate($volumeHandle = null)
74 74
     {
75
-        echo 'Creating optimized image variants' . PHP_EOL;
75
+        echo 'Creating optimized image variants'.PHP_EOL;
76 76
         if ($this->force) {
77
-            echo 'Forcing optimized image variants creation via --force' . PHP_EOL;
77
+            echo 'Forcing optimized image variants creation via --force'.PHP_EOL;
78 78
         }
79 79
 
80 80
         $fieldId = null;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                 /** @var Volume $volume */
96 96
                 ImageOptimize::$plugin->optimizedImages->resaveVolumeAssets($volume, $fieldId, $this->force);
97 97
             } else {
98
-                echo 'Unknown Asset Volume handle: ' . $volumeHandle . PHP_EOL;
98
+                echo 'Unknown Asset Volume handle: '.$volumeHandle.PHP_EOL;
99 99
             }
100 100
         }
101 101
         if (!$this->queue) {
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function actionCreateAsset($id = null)
112 112
     {
113
-        echo 'Creating optimized image variants' . PHP_EOL;
113
+        echo 'Creating optimized image variants'.PHP_EOL;
114 114
 
115 115
         if ($id === null) {
116
-            echo 'No Asset ID specified' . PHP_EOL;
116
+            echo 'No Asset ID specified'.PHP_EOL;
117 117
         } else {
118 118
             // Re-save a single Asset ID
119 119
             ImageOptimize::$plugin->optimizedImages->resaveAsset($id, $this->force);
Please login to merge, or discard this patch.
ecs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 
6 6
 return static function(ECSConfig $ecsConfig): void {
7 7
     $ecsConfig->paths([
8
-        __DIR__ . '/src',
8
+        __DIR__.'/src',
9 9
         __FILE__,
10 10
     ]);
11 11
     $ecsConfig->parallel();
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.