| @@ -53,8 +53,8 @@ | ||
| 53 | 53 | // It takes a bit of time, so if you never plan to use it, you can turn it off | 
| 54 | 54 | 'createColorPalette' => true, | 
| 55 | 55 | |
| 56 | - // Controls whether SVG placeholder silhouettes should be created for image variants | |
| 57 | - // It takes a bit of time, so if you never plan to use them, you can turn it off | |
| 56 | + // Controls whether SVG placeholder silhouettes should be created for image variants | |
| 57 | + // It takes a bit of time, so if you never plan to use them, you can turn it off | |
| 58 | 58 | 'createPlaceholderSilhouettes' => true, | 
| 59 | 59 | |
| 60 | 60 | // Controls whether retina images are automatically created with reduced quality | 
| @@ -367,7 +367,7 @@ discard block | ||
| 367 | 367 | */ | 
| 368 | 368 | public function getPlaceholderImage(): string | 
| 369 | 369 |      { | 
| 370 | - return (string)$this->placeholderImage(); | |
| 370 | + return (string) $this->placeholderImage(); | |
| 371 | 371 | } | 
| 372 | 372 | |
| 373 | 373 | /** | 
| @@ -404,7 +404,7 @@ discard block | ||
| 404 | 404 | */ | 
| 405 | 405 | public function getPlaceholderBox(string $color = null): string | 
| 406 | 406 |      { | 
| 407 | - return (string)$this->placeholderBox($color); | |
| 407 | + return (string) $this->placeholderBox($color); | |
| 408 | 408 | } | 
| 409 | 409 | |
| 410 | 410 | /** | 
| @@ -445,7 +445,7 @@ discard block | ||
| 445 | 445 | */ | 
| 446 | 446 | public function getPlaceholderSilhouette(): string | 
| 447 | 447 |      { | 
| 448 | - return (string)$this->placeholderSilhouette(); | |
| 448 | + return (string) $this->placeholderSilhouette(); | |
| 449 | 449 | } | 
| 450 | 450 | |
| 451 | 451 | /** | 
| @@ -557,10 +557,10 @@ discard block | ||
| 557 | 557 |          foreach ($array as $key => $value) { | 
| 558 | 558 |              if ($dpr) { | 
| 559 | 559 | $descriptor = '1x'; | 
| 560 | -                if (!empty($array[(int)$key / 2])) { | |
| 560 | +                if (!empty($array[(int) $key / 2])) { | |
| 561 | 561 | $descriptor = '2x'; | 
| 562 | 562 | } | 
| 563 | -                if (!empty($array[(int)$key / 3])) { | |
| 563 | +                if (!empty($array[(int) $key / 3])) { | |
| 564 | 564 | $descriptor = '3x'; | 
| 565 | 565 | } | 
| 566 | 566 |              } else { | 
| @@ -39,16 +39,16 @@ | ||
| 39 | 39 | |
| 40 | 40 | // Primary getter functions | 
| 41 | 41 |          $fieldObject->addStringField('src') | 
| 42 | -            ->arguments(function (\markhuot\CraftQL\Builders\Field $field) { | |
| 42 | +            ->arguments(function(\markhuot\CraftQL\Builders\Field $field) { | |
| 43 | 43 |                  $field->addIntArgument('width'); | 
| 44 | 44 | }) | 
| 45 | -            ->resolve(function ($root, $args) { | |
| 45 | +            ->resolve(function($root, $args) { | |
| 46 | 46 | return $root->src(@$args['width'] ?: 0); | 
| 47 | 47 | }); | 
| 48 | 48 |          $fieldObject->addField('srcUrls') | 
| 49 | 49 | ->lists() | 
| 50 | 50 | ->type($srcObject) | 
| 51 | -            ->resolve(function ($root, $args) { | |
| 51 | +            ->resolve(function($root, $args) { | |
| 52 | 52 | $result = []; | 
| 53 | 53 |                  foreach ($root->optimizedImageUrls as $width => $url) { | 
| 54 | 54 | $result[] = ['width' => $width, 'url' => $url]; | 
| @@ -403,7 +403,7 @@ discard block | ||
| 403 | 403 | $cache = Craft::$app->getCache(); | 
| 404 | 404 | $file = $cache->getOrSet( | 
| 405 | 405 | self::CACHE_KEY.$path, | 
| 406 | -            function () use ($path, $callback) { | |
| 406 | +            function() use ($path, $callback) { | |
| 407 | 407 | $result = null; | 
| 408 | 408 | $contents = @file_get_contents($path); | 
| 409 | 409 |                  if ($contents) { | 
| @@ -433,7 +433,7 @@ discard block | ||
| 433 | 433 | protected static function combinePaths(string ...$paths): string | 
| 434 | 434 |      { | 
| 435 | 435 | $last_key = \count($paths) - 1; | 
| 436 | -        array_walk($paths, function (&$val, $key) use ($last_key) { | |
| 436 | +        array_walk($paths, function(&$val, $key) use ($last_key) { | |
| 437 | 437 |              switch ($key) { | 
| 438 | 438 | case 0: | 
| 439 | 439 | $val = rtrim($val, '/ '); | 
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | self::$config['server']['publicPath'] = $baseAssetsUrl; | 
| 52 | 52 |          $useDevServer = getenv('NYS_PLUGIN_DEVSERVER'); | 
| 53 | 53 |          if ($useDevServer !== false) { | 
| 54 | - self::$config['useDevServer'] = (bool)$useDevServer; | |
| 54 | + self::$config['useDevServer'] = (bool) $useDevServer; | |
| 55 | 55 | } | 
| 56 | 56 | } | 
| 57 | 57 | |
| @@ -385,11 +385,11 @@ | ||
| 385 | 385 | } | 
| 386 | 386 | $width = $variant['width'] * $retinaSize; | 
| 387 | 387 | $transform->width = $width; | 
| 388 | - $transform->height = (int)($width / $aspectRatio); | |
| 388 | + $transform->height = (int) ($width / $aspectRatio); | |
| 389 | 389 | // Image quality | 
| 390 | 390 | $quality = $variant['quality'] ?? null; | 
| 391 | 391 |          if ($settings->lowerQualityRetinaImageVariants && $retinaSize != '1') { | 
| 392 | - $quality = (int)($quality * (1.5 / (int)$retinaSize)); | |
| 392 | + $quality = (int) ($quality * (1.5 / (int) $retinaSize)); | |
| 393 | 393 | } | 
| 394 | 394 | $transform->quality = $quality; | 
| 395 | 395 | // Interlaced (progressive JPEGs or interlaced PNGs) | 
| @@ -231,7 +231,7 @@ discard block | ||
| 231 | 231 | Event::on( | 
| 232 | 232 | CraftVariable::class, | 
| 233 | 233 | CraftVariable::EVENT_INIT, | 
| 234 | -            function (Event $event) { | |
| 234 | +            function(Event $event) { | |
| 235 | 235 | /** @var CraftVariable $variable */ | 
| 236 | 236 | $variable = $event->sender; | 
| 237 | 237 |                  $variable->set('imageOptimize', ImageOptimizeVariable::class); | 
| @@ -242,7 +242,7 @@ discard block | ||
| 242 | 242 | Event::on( | 
| 243 | 243 | Fields::class, | 
| 244 | 244 | Fields::EVENT_REGISTER_FIELD_TYPES, | 
| 245 | -            function (RegisterComponentTypesEvent $event) { | |
| 245 | +            function(RegisterComponentTypesEvent $event) { | |
| 246 | 246 | Craft::debug( | 
| 247 | 247 | 'Fields::EVENT_REGISTER_FIELD_TYPES', | 
| 248 | 248 | __METHOD__ | 
| @@ -281,7 +281,7 @@ discard block | ||
| 281 | 281 | Event::on( | 
| 282 | 282 | Assets::class, | 
| 283 | 283 | Assets::EVENT_GET_ASSET_URL, | 
| 284 | -            function (GetAssetUrlEvent $event) { | |
| 284 | +            function(GetAssetUrlEvent $event) { | |
| 285 | 285 | Craft::debug( | 
| 286 | 286 | 'Assets::EVENT_GET_ASSET_URL', | 
| 287 | 287 | __METHOD__ | 
| @@ -297,7 +297,7 @@ discard block | ||
| 297 | 297 | Event::on( | 
| 298 | 298 | Assets::class, | 
| 299 | 299 | Assets::EVENT_GET_ASSET_THUMB_URL, | 
| 300 | -            function (GetAssetThumbUrlEvent $event) { | |
| 300 | +            function(GetAssetThumbUrlEvent $event) { | |
| 301 | 301 | Craft::debug( | 
| 302 | 302 | 'Assets::EVENT_GET_ASSET_THUMB_URL', | 
| 303 | 303 | __METHOD__ | 
| @@ -313,7 +313,7 @@ discard block | ||
| 313 | 313 | Event::on( | 
| 314 | 314 | AssetTransforms::class, | 
| 315 | 315 | AssetTransforms::EVENT_GENERATE_TRANSFORM, | 
| 316 | -            function (GenerateTransformEvent $event) { | |
| 316 | +            function(GenerateTransformEvent $event) { | |
| 317 | 317 | Craft::debug( | 
| 318 | 318 | 'AssetTransforms::EVENT_GENERATE_TRANSFORM', | 
| 319 | 319 | __METHOD__ | 
| @@ -329,7 +329,7 @@ discard block | ||
| 329 | 329 | Event::on( | 
| 330 | 330 | AssetTransforms::class, | 
| 331 | 331 | AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS, | 
| 332 | -            function (AssetTransformImageEvent $event) { | |
| 332 | +            function(AssetTransformImageEvent $event) { | |
| 333 | 333 | Craft::debug( | 
| 334 | 334 | 'AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS', | 
| 335 | 335 | __METHOD__ | 
| @@ -345,7 +345,7 @@ discard block | ||
| 345 | 345 | Event::on( | 
| 346 | 346 | Assets::class, | 
| 347 | 347 | Assets::EVENT_BEFORE_REPLACE_ASSET, | 
| 348 | -            function (ReplaceAssetEvent $event) { | |
| 348 | +            function(ReplaceAssetEvent $event) { | |
| 349 | 349 | Craft::debug( | 
| 350 | 350 | 'Assets::EVENT_BEFORE_REPLACE_ASSET', | 
| 351 | 351 | __METHOD__ | 
| @@ -367,7 +367,7 @@ discard block | ||
| 367 | 367 | Event::on( | 
| 368 | 368 | Assets::class, | 
| 369 | 369 | Assets::EVENT_AFTER_REPLACE_ASSET, | 
| 370 | -            function (ReplaceAssetEvent $event) { | |
| 370 | +            function(ReplaceAssetEvent $event) { | |
| 371 | 371 | Craft::debug( | 
| 372 | 372 | 'Assets::EVENT_AFTER_REPLACE_ASSET', | 
| 373 | 373 | __METHOD__ | 
| @@ -390,7 +390,7 @@ discard block | ||
| 390 | 390 | Event::on( | 
| 391 | 391 | Assets::class, | 
| 392 | 392 | Elements::EVENT_BEFORE_SAVE_ELEMENT, | 
| 393 | -            function (ElementEvent $event) { | |
| 393 | +            function(ElementEvent $event) { | |
| 394 | 394 | Craft::debug( | 
| 395 | 395 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', | 
| 396 | 396 | __METHOD__ | 
| @@ -414,7 +414,7 @@ discard block | ||
| 414 | 414 | Event::on( | 
| 415 | 415 | Asset::class, | 
| 416 | 416 | Elements::EVENT_BEFORE_DELETE_ELEMENT, | 
| 417 | -            function (ElementEvent $event) { | |
| 417 | +            function(ElementEvent $event) { | |
| 418 | 418 | Craft::debug( | 
| 419 | 419 | 'Elements::EVENT_BEFORE_DELETE_ELEMENT', | 
| 420 | 420 | __METHOD__ | 
| @@ -442,7 +442,7 @@ discard block | ||
| 442 | 442 | Event::on( | 
| 443 | 443 | Fields::class, | 
| 444 | 444 | Fields::EVENT_AFTER_SAVE_FIELD, | 
| 445 | -            function (FieldEvent $event) { | |
| 445 | +            function(FieldEvent $event) { | |
| 446 | 446 | Craft::debug( | 
| 447 | 447 | 'Fields::EVENT_AFTER_SAVE_FIELD', | 
| 448 | 448 | __METHOD__ | 
| @@ -459,7 +459,7 @@ discard block | ||
| 459 | 459 | Event::on( | 
| 460 | 460 | Plugins::class, | 
| 461 | 461 | Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS, | 
| 462 | -            function (PluginEvent $event) { | |
| 462 | +            function(PluginEvent $event) { | |
| 463 | 463 |                  if ($event->plugin === $this) { | 
| 464 | 464 | Craft::debug( | 
| 465 | 465 | 'Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS', | 
| @@ -478,7 +478,7 @@ discard block | ||
| 478 | 478 | Event::on( | 
| 479 | 479 | Volumes::class, | 
| 480 | 480 | Volumes::EVENT_AFTER_SAVE_VOLUME, | 
| 481 | -            function (VolumeEvent $event) { | |
| 481 | +            function(VolumeEvent $event) { | |
| 482 | 482 | Craft::debug( | 
| 483 | 483 | 'Volumes::EVENT_AFTER_SAVE_VOLUME', | 
| 484 | 484 | __METHOD__ | 
| @@ -499,7 +499,7 @@ discard block | ||
| 499 | 499 | Event::on( | 
| 500 | 500 | Plugins::class, | 
| 501 | 501 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, | 
| 502 | -            function (PluginEvent $event) { | |
| 502 | +            function(PluginEvent $event) { | |
| 503 | 503 |                  if ($event->plugin === $this) { | 
| 504 | 504 | $request = Craft::$app->getRequest(); | 
| 505 | 505 |                      if ($request->isCpRequest) { | 
| @@ -533,7 +533,7 @@ discard block | ||
| 533 | 533 | Event::on( | 
| 534 | 534 | UrlManager::class, | 
| 535 | 535 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, | 
| 536 | -            function (RegisterUrlRulesEvent $event) { | |
| 536 | +            function(RegisterUrlRulesEvent $event) { | |
| 537 | 537 | Craft::debug( | 
| 538 | 538 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', | 
| 539 | 539 | __METHOD__ | 
| @@ -556,12 +556,12 @@ discard block | ||
| 556 | 556 | Event::on( | 
| 557 | 557 | Plugins::class, | 
| 558 | 558 | Plugins::EVENT_AFTER_LOAD_PLUGINS, | 
| 559 | -            function () { | |
| 559 | +            function() { | |
| 560 | 560 | // Install these only after all other plugins have loaded | 
| 561 | 561 | Event::on( | 
| 562 | 562 | View::class, | 
| 563 | 563 | View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, | 
| 564 | -                        function (RegisterTemplateRootsEvent $e) { | |
| 564 | +                        function(RegisterTemplateRootsEvent $e) { | |
| 565 | 565 | // Register the root directodies | 
| 566 | 566 | $allImageTransformTypes = ImageOptimize::$plugin->optimize->getAllImageTransformTypes(); | 
| 567 | 567 | /** @var ImageTransformInterface $imageTransformType */ | 
| @@ -84,7 +84,7 @@ discard block | ||
| 84 | 84 |          Craft::beginProfile('generatePlaceholderImage', __METHOD__); | 
| 85 | 85 | $result = ''; | 
| 86 | 86 | $width = self::PLACEHOLDER_WIDTH; | 
| 87 | - $height = (int)($width / $aspectRatio); | |
| 87 | + $height = (int) ($width / $aspectRatio); | |
| 88 | 88 | $placeholderPath = $this->createImageFromPath($tempPath, $width, $height, self::PLACEHOLDER_QUALITY, $position); | 
| 89 | 89 |          if (!empty($placeholderPath)) { | 
| 90 | 90 | $result = base64_encode(file_get_contents($placeholderPath)); | 
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | $lightness /= $colorCount; | 
| 149 | 149 | } | 
| 150 | 150 | |
| 151 | - return $lightness === null ? $lightness : (int)$lightness; | |
| 151 | + return $lightness === null ? $lightness : (int) $lightness; | |
| 152 | 152 | } | 
| 153 | 153 | /** | 
| 154 | 154 | * Generate an SVG image via Potrace | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 |      { | 
| 208 | 208 |          Craft::beginProfile('createTempPlaceholderImage', __METHOD__); | 
| 209 | 209 | $width = self::TEMP_PLACEHOLDER_WIDTH; | 
| 210 | - $height = (int)($width / $aspectRatio); | |
| 210 | + $height = (int) ($width / $aspectRatio); | |
| 211 | 211 | $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position); | 
| 212 | 212 |          Craft::endProfile('createTempPlaceholderImage', __METHOD__); | 
| 213 | 213 | |
| @@ -58,9 +58,9 @@ discard block | ||
| 58 | 58 | */ | 
| 59 | 59 | public static function RGBToHSL(array $rgb): array | 
| 60 | 60 |      { | 
| 61 | - $r = ((float)$rgb['r']) / 255.0; | |
| 62 | - $g = ((float)$rgb['g']) / 255.0; | |
| 63 | - $b = ((float)$rgb['b']) / 255.0; | |
| 61 | + $r = ((float) $rgb['r']) / 255.0; | |
| 62 | + $g = ((float) $rgb['g']) / 255.0; | |
| 63 | + $b = ((float) $rgb['b']) / 255.0; | |
| 64 | 64 | |
| 65 | 65 | $maxC = max($r, $g, $b); | 
| 66 | 66 | $minC = min($r, $g, $b); | 
| @@ -88,9 +88,9 @@ discard block | ||
| 88 | 88 | $h /= 6.0; | 
| 89 | 89 | } | 
| 90 | 90 | |
| 91 | - $h = (int)round(360.0 * $h); | |
| 92 | - $s = (int)round(100.0 * $s); | |
| 93 | - $l = (int)round(100.0 * $l); | |
| 91 | + $h = (int) round(360.0 * $h); | |
| 92 | + $s = (int) round(100.0 * $s); | |
| 93 | + $l = (int) round(100.0 * $l); | |
| 94 | 94 | |
| 95 | 95 | return ['h' => $h, 's' => $s, 'l' => $l]; | 
| 96 | 96 | } |