@@ -45,7 +45,7 @@ discard block |
||
| 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 |
||
| 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 |
@@ -64,7 +64,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -57,7 +57,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -37,12 +37,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -41,8 +41,8 @@ discard block |
||
| 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 |
||
| 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 | ], |
@@ -137,7 +137,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 */ |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function actionCreate(?string $volumeHandle = null): void |
| 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; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if ($volume) { |
| 93 | 93 | ImageOptimize::$plugin->optimizedImages->resaveVolumeAssets($volume, $fieldId, $this->force); |
| 94 | 94 | } else { |
| 95 | - echo 'Unknown Asset Volume handle: ' . $volumeHandle . PHP_EOL; |
|
| 95 | + echo 'Unknown Asset Volume handle: '.$volumeHandle.PHP_EOL; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | if (!$this->queue) { |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function actionCreateAsset(?int $id = null): void |
| 109 | 109 | { |
| 110 | - echo 'Creating optimized image variants' . PHP_EOL; |
|
| 110 | + echo 'Creating optimized image variants'.PHP_EOL; |
|
| 111 | 111 | |
| 112 | 112 | if ($id === null) { |
| 113 | - echo 'No Asset ID specified' . PHP_EOL; |
|
| 113 | + echo 'No Asset ID specified'.PHP_EOL; |
|
| 114 | 114 | } else { |
| 115 | 115 | // Re-save a single Asset ID |
| 116 | 116 | ImageOptimize::$plugin->optimizedImages->resaveAsset($id, $this->force); |
@@ -5,7 +5,7 @@ |
||
| 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(); |