@@ -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 | |
@@ -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; |
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | if (!$asset->propagating) { |
| 208 | 208 | // If the scenario is Asset::SCENARIO_FILEOPS treat it as a new asset |
| 209 | 209 | $scenario = $asset->getScenario(); |
| 210 | - if ($isNew || $scenario === Asset::SCENARIO_FILEOPS ) { |
|
| 210 | + if ($isNew || $scenario === Asset::SCENARIO_FILEOPS) { |
|
| 211 | 211 | /** |
| 212 | 212 | * If this is a newly uploaded/created Asset, we can save the variants |
| 213 | 213 | * via a queue job to prevent it from blocking |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $index->fileExists = 0; |
| 111 | 111 | $transforms->storeTransformIndexData($index); |
| 112 | 112 | $volume = $asset->getVolume(); |
| 113 | - $transformPath = $asset->folderPath . $transforms->getTransformSubpath($asset, $index); |
|
| 113 | + $transformPath = $asset->folderPath.$transforms->getTransformSubpath($asset, $index); |
|
| 114 | 114 | try { |
| 115 | 115 | $volume->deleteFile($transformPath); |
| 116 | 116 | } catch (\Throwable $exception) { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $msg = 'Failed to update transform: '.$e->getMessage(); |
| 120 | 120 | Craft::error($msg, __METHOD__); |
| 121 | 121 | if (Craft::$app instanceof ConsoleApplication) { |
| 122 | - echo $msg . PHP_EOL; |
|
| 122 | + echo $msg.PHP_EOL; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | __METHOD__ |
| 141 | 141 | ); |
| 142 | 142 | if (Craft::$app instanceof ConsoleApplication) { |
| 143 | - echo $msg . PHP_EOL; |
|
| 143 | + echo $msg.PHP_EOL; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $folder = $asset->getFolder(); |
| 201 | 201 | while ($folder !== null && !$createVariants) { |
| 202 | 202 | if ($folder->uid === $subfolder) { |
| 203 | - Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__); |
|
| 203 | + Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__); |
|
| 204 | 204 | $createVariants = true; |
| 205 | 205 | } else { |
| 206 | 206 | $folder = $folder->getParent(); |
@@ -478,20 +478,20 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | $useAspectRatio = $variant['useAspectRatio'] ?? false; |
| 480 | 480 | if ($useAspectRatio) { |
| 481 | - $aspectRatio = (int)$variant['aspectRatioX'] / (int)$variant['aspectRatioY']; |
|
| 481 | + $aspectRatio = (int) $variant['aspectRatioX'] / (int) $variant['aspectRatioY']; |
|
| 482 | 482 | } else { |
| 483 | - $aspectRatio = (int)$asset->width / (int)$asset->height; |
|
| 483 | + $aspectRatio = (int) $asset->width / (int) $asset->height; |
|
| 484 | 484 | } |
| 485 | - $width = (int)$variant['width'] * (int)$retinaSize; |
|
| 485 | + $width = (int) $variant['width'] * (int) $retinaSize; |
|
| 486 | 486 | $transform->width = $width; |
| 487 | - $transform->height = (int)($width / $aspectRatio); |
|
| 487 | + $transform->height = (int) ($width / $aspectRatio); |
|
| 488 | 488 | // Image quality |
| 489 | - $quality = (int)($variant['quality'] ?? null); |
|
| 489 | + $quality = (int) ($variant['quality'] ?? null); |
|
| 490 | 490 | if (empty($quality)) { |
| 491 | 491 | $quality = null; |
| 492 | 492 | } |
| 493 | 493 | if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') { |
| 494 | - $quality = (int)($quality * (1.5 / (int)$retinaSize)); |
|
| 494 | + $quality = (int) ($quality * (1.5 / (int) $retinaSize)); |
|
| 495 | 495 | } |
| 496 | 496 | $transform->quality = $quality; |
| 497 | 497 | // Interlaced (progressive JPEGs or interlaced PNGs) |