@@ -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 |
@@ -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 | } |
@@ -188,12 +188,12 @@ |
||
188 | 188 | ?: GqlEntityRegistry::createEntity($typeName, new OptimizedImagesType([ |
189 | 189 | 'name' => $typeName, |
190 | 190 | 'description' => 'This entity has all the OptimizedImages properties', |
191 | - 'fields' => function () use ($optimizedImagesFields) { |
|
191 | + 'fields' => function() use ($optimizedImagesFields) { |
|
192 | 192 | return $optimizedImagesFields; |
193 | 193 | }, |
194 | 194 | ])); |
195 | 195 | |
196 | - TypeLoader::registerType($typeName, function () use ($optimizedImagesType) { |
|
196 | + TypeLoader::registerType($typeName, function() use ($optimizedImagesType) { |
|
197 | 197 | return $optimizedImagesType; |
198 | 198 | }); |
199 | 199 |
@@ -148,14 +148,14 @@ discard block |
||
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 |
||
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; |
@@ -88,7 +88,7 @@ discard block |
||
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 |
||
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 |
||
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 | * Generate an SVG image via Potrace |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | __METHOD__ |
220 | 220 | ); |
221 | 221 | $width = self::TEMP_PLACEHOLDER_WIDTH; |
222 | - $height = (int)($width / $aspectRatio); |
|
222 | + $height = (int) ($width / $aspectRatio); |
|
223 | 223 | $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position); |
224 | 224 | Craft::endProfile('createTempPlaceholderImage', __METHOD__); |
225 | 225 |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | while ($currentElement < $totalElements) { |
92 | 92 | $elements = $paginator->getPageResults(); |
93 | 93 | if (Craft::$app instanceof ConsoleApplication) { |
94 | - echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages() |
|
95 | - . ' - assets: ' . $paginator->getTotalResults() |
|
94 | + echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages() |
|
95 | + . ' - assets: '.$paginator->getTotalResults() |
|
96 | 96 | . PHP_EOL; |
97 | 97 | } |
98 | 98 | /** @var ElementInterface $element */ |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | if ($field instanceof OptimizedImagesField && $element instanceof Asset) { |
108 | 108 | if ($this->fieldId === null || $field->id == $this->fieldId) { |
109 | 109 | if (Craft::$app instanceof ConsoleApplication) { |
110 | - echo $currentElement . '/' . $totalElements |
|
111 | - . ' - processing asset: ' . $element->title |
|
112 | - . ' from field: ' . $field->name . PHP_EOL; |
|
110 | + echo $currentElement.'/'.$totalElements |
|
111 | + . ' - processing asset: '.$element->title |
|
112 | + . ' from field: '.$field->name.PHP_EOL; |
|
113 | 113 | } |
114 | 114 | try { |
115 | 115 | ImageOptimize::$plugin->optimizedImages->updateOptimizedImageFieldData($field, $element, $this->force); |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | echo '[error]: ' |
120 | 120 | . $e->getMessage() |
121 | 121 | . ' while processing ' |
122 | - . $currentElement . '/' . $totalElements |
|
123 | - . ' - processing asset: ' . $element->title |
|
124 | - . ' from field: ' . $field->name . PHP_EOL; |
|
122 | + . $currentElement.'/'.$totalElements |
|
123 | + . ' - processing asset: '.$element->title |
|
124 | + . ' from field: '.$field->name.PHP_EOL; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | Event::on( |
235 | 235 | CraftVariable::class, |
236 | 236 | CraftVariable::EVENT_INIT, |
237 | - function (Event $event) { |
|
237 | + function(Event $event) { |
|
238 | 238 | /** @var CraftVariable $variable */ |
239 | 239 | $variable = $event->sender; |
240 | 240 | $variable->set('imageOptimize', ImageOptimizeVariable::class); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | Event::on( |
246 | 246 | Fields::class, |
247 | 247 | Fields::EVENT_REGISTER_FIELD_TYPES, |
248 | - function (RegisterComponentTypesEvent $event) { |
|
248 | + function(RegisterComponentTypesEvent $event) { |
|
249 | 249 | Craft::debug( |
250 | 250 | 'Fields::EVENT_REGISTER_FIELD_TYPES', |
251 | 251 | __METHOD__ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | Event::on( |
260 | 260 | Utilities::class, |
261 | 261 | Utilities::EVENT_REGISTER_UTILITY_TYPES, |
262 | - function (RegisterComponentTypesEvent $event) { |
|
262 | + function(RegisterComponentTypesEvent $event) { |
|
263 | 263 | $event->types[] = ImageOptimizeUtility::class; |
264 | 264 | } |
265 | 265 | ); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | Event::on( |
296 | 296 | Assets::class, |
297 | 297 | Assets::EVENT_GET_ASSET_URL, |
298 | - function (GetAssetUrlEvent $event) { |
|
298 | + function(GetAssetUrlEvent $event) { |
|
299 | 299 | Craft::debug( |
300 | 300 | 'Assets::EVENT_GET_ASSET_URL', |
301 | 301 | __METHOD__ |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | Event::on( |
312 | 312 | Assets::class, |
313 | 313 | Assets::EVENT_GET_ASSET_THUMB_URL, |
314 | - function (GetAssetThumbUrlEvent $event) { |
|
314 | + function(GetAssetThumbUrlEvent $event) { |
|
315 | 315 | Craft::debug( |
316 | 316 | 'Assets::EVENT_GET_ASSET_THUMB_URL', |
317 | 317 | __METHOD__ |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | Event::on( |
328 | 328 | AssetTransforms::class, |
329 | 329 | AssetTransforms::EVENT_GENERATE_TRANSFORM, |
330 | - function (GenerateTransformEvent $event) { |
|
330 | + function(GenerateTransformEvent $event) { |
|
331 | 331 | Craft::debug( |
332 | 332 | 'AssetTransforms::EVENT_GENERATE_TRANSFORM', |
333 | 333 | __METHOD__ |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | Event::on( |
344 | 344 | AssetTransforms::class, |
345 | 345 | AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS, |
346 | - function (AssetTransformImageEvent $event) { |
|
346 | + function(AssetTransformImageEvent $event) { |
|
347 | 347 | Craft::debug( |
348 | 348 | 'AssetTransforms::EVENT_AFTER_DELETE_TRANSFORMS', |
349 | 349 | __METHOD__ |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | Event::on( |
360 | 360 | Assets::class, |
361 | 361 | Assets::EVENT_BEFORE_REPLACE_ASSET, |
362 | - function (ReplaceAssetEvent $event) { |
|
362 | + function(ReplaceAssetEvent $event) { |
|
363 | 363 | Craft::debug( |
364 | 364 | 'Assets::EVENT_BEFORE_REPLACE_ASSET', |
365 | 365 | __METHOD__ |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | Event::on( |
379 | 379 | Assets::class, |
380 | 380 | Assets::EVENT_AFTER_REPLACE_ASSET, |
381 | - function (ReplaceAssetEvent $event) { |
|
381 | + function(ReplaceAssetEvent $event) { |
|
382 | 382 | Craft::debug( |
383 | 383 | 'Assets::EVENT_AFTER_REPLACE_ASSET', |
384 | 384 | __METHOD__ |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | Event::on( |
402 | 402 | Assets::class, |
403 | 403 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
404 | - function (ElementEvent $event) { |
|
404 | + function(ElementEvent $event) { |
|
405 | 405 | Craft::debug( |
406 | 406 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
407 | 407 | __METHOD__ |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | Event::on( |
423 | 423 | Asset::class, |
424 | 424 | Elements::EVENT_BEFORE_DELETE_ELEMENT, |
425 | - function (ElementEvent $event) { |
|
425 | + function(ElementEvent $event) { |
|
426 | 426 | Craft::debug( |
427 | 427 | 'Elements::EVENT_BEFORE_DELETE_ELEMENT', |
428 | 428 | __METHOD__ |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | Event::on( |
448 | 448 | Fields::class, |
449 | 449 | Fields::EVENT_AFTER_SAVE_FIELD, |
450 | - function (FieldEvent $event) { |
|
450 | + function(FieldEvent $event) { |
|
451 | 451 | Craft::debug( |
452 | 452 | 'Fields::EVENT_AFTER_SAVE_FIELD', |
453 | 453 | __METHOD__ |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | Event::on( |
465 | 465 | Plugins::class, |
466 | 466 | Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS, |
467 | - function (PluginEvent $event) { |
|
467 | + function(PluginEvent $event) { |
|
468 | 468 | if ($event->plugin === $this) { |
469 | 469 | Craft::debug( |
470 | 470 | 'Plugins::EVENT_AFTER_SAVE_PLUGIN_SETTINGS', |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | Event::on( |
484 | 484 | Volumes::class, |
485 | 485 | Volumes::EVENT_AFTER_SAVE_VOLUME, |
486 | - function (VolumeEvent $event) { |
|
486 | + function(VolumeEvent $event) { |
|
487 | 487 | Craft::debug( |
488 | 488 | 'Volumes::EVENT_AFTER_SAVE_VOLUME', |
489 | 489 | __METHOD__ |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | Event::on( |
505 | 505 | Plugins::class, |
506 | 506 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
507 | - function (PluginEvent $event) { |
|
507 | + function(PluginEvent $event) { |
|
508 | 508 | if ($event->plugin === $this) { |
509 | 509 | $request = Craft::$app->getRequest(); |
510 | 510 | if ($request->isCpRequest) { |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | Event::on( |
539 | 539 | UrlManager::class, |
540 | 540 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
541 | - function (RegisterUrlRulesEvent $event) { |
|
541 | + function(RegisterUrlRulesEvent $event) { |
|
542 | 542 | Craft::debug( |
543 | 543 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
544 | 544 | __METHOD__ |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | Event::on( |
562 | 562 | Plugins::class, |
563 | 563 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
564 | - function () { |
|
564 | + function() { |
|
565 | 565 | // Install these only after all other plugins have loaded |
566 | 566 | Event::on( |
567 | 567 | View::class, |
568 | 568 | View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, |
569 | - function (RegisterTemplateRootsEvent $e) { |
|
569 | + function(RegisterTemplateRootsEvent $e) { |
|
570 | 570 | // Register the root directodies |
571 | 571 | $allImageTransformTypes = ImageOptimize::$plugin->optimize->getAllImageTransformTypes(); |
572 | 572 | /** @var ImageTransformInterface $imageTransformType */ |