@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | ]; |
| 110 | 110 | // Normalize the min |
| 111 | 111 | if (!empty($this->min)) { |
| 112 | - $config['value'] = (float)$this->min; |
|
| 112 | + $config['value'] = (float) $this->min; |
|
| 113 | 113 | $baseUnit = new UnitsData($config); |
| 114 | 114 | $this->min = $baseUnit->toUnit($unitsData->units); |
| 115 | 115 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | // Normalize the max |
| 119 | 119 | if (!empty($this->max)) { |
| 120 | - $config['value'] = (float)$this->max; |
|
| 120 | + $config['value'] = (float) $this->max; |
|
| 121 | 121 | $baseUnit = new UnitsData($config); |
| 122 | 122 | $this->max = $baseUnit->toUnit($unitsData->units); |
| 123 | 123 | } else { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public static function dump($dirs, $file) |
| 27 | 27 | { |
| 28 | - $dirs = (array)$dirs; |
|
| 28 | + $dirs = (array) $dirs; |
|
| 29 | 29 | $maps = []; |
| 30 | 30 | foreach ($dirs as $dir) { |
| 31 | 31 | $maps = array_merge($maps, static::createMap($dir)); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | break; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - $classes[] = ltrim($namespace . $class, '\\'); |
|
| 135 | + $classes[] = ltrim($namespace.$class, '\\'); |
|
| 136 | 136 | break; |
| 137 | 137 | default: |
| 138 | 138 | break; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function toFraction(): string |
| 207 | 207 | { |
| 208 | - return trim(Units::$variable->fraction($this->value) . ' ' . $this->units); |
|
| 208 | + return trim(Units::$variable->fraction($this->value).' '.$this->units); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | public function getValuePartsFraction(): array |
| 256 | 256 | { |
| 257 | 257 | $parts = Units::$variable->float2parts($this->value); |
| 258 | - $parts[0] = (string)$parts[0]; |
|
| 258 | + $parts[0] = (string) $parts[0]; |
|
| 259 | 259 | $parts[1] = Units::$variable->float2ratio($parts[1]); |
| 260 | 260 | |
| 261 | 261 | return $parts; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | protected function physicalQuantityToUnitsData(PhysicalQuantityInterface $quantity): UnitsData |
| 275 | 275 | { |
| 276 | 276 | $unitsClass = get_class($quantity); |
| 277 | - list($value, $units) = explode(' ', (string)$quantity); |
|
| 277 | + list($value, $units) = explode(' ', (string) $quantity); |
|
| 278 | 278 | $config = [ |
| 279 | 279 | 'unitsClass' => $unitsClass, |
| 280 | 280 | 'value' => $value, |
@@ -46,12 +46,12 @@ |
||
| 46 | 46 | /** |
| 47 | 47 | * @var int|float The default minimum allowed number |
| 48 | 48 | */ |
| 49 | - public int|float $defaultMin = 0; |
|
| 49 | + public int | float $defaultMin = 0; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @var int|float|null The default maximum allowed number |
| 53 | 53 | */ |
| 54 | - public int|null|float $defaultMax = null; |
|
| 54 | + public int | null | float $defaultMax = null; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @var int The default number of digits allowed after the decimal point |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * @inheritdoc |
| 29 | 29 | */ |
| 30 | - protected array|bool|int $allowAnonymous = [ |
|
| 30 | + protected array | bool | int $allowAnonymous = [ |
|
| 31 | 31 | 'all-available-units', |
| 32 | 32 | 'available-units', |
| 33 | 33 | ]; |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | { |
| 107 | 107 | [$whole, $decimal] = $this->float2parts($value); |
| 108 | 108 | |
| 109 | - return $whole . ' ' . $this->float2ratio($decimal); |
|
| 109 | + return $whole.' '.$this->float2ratio($decimal); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | Event::on( |
| 77 | 77 | Fields::class, |
| 78 | 78 | Fields::EVENT_REGISTER_FIELD_TYPES, |
| 79 | - static function (RegisterComponentTypesEvent $event) { |
|
| 79 | + static function(RegisterComponentTypesEvent $event) { |
|
| 80 | 80 | $event->types[] = UnitsField::class; |
| 81 | 81 | } |
| 82 | 82 | ); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | Event::on( |
| 86 | 86 | CraftVariable::class, |
| 87 | 87 | CraftVariable::EVENT_INIT, |
| 88 | - static function (Event $event) { |
|
| 88 | + static function(Event $event) { |
|
| 89 | 89 | /** @var CraftVariable $variable */ |
| 90 | 90 | $variable = $event->sender; |
| 91 | 91 | $variable->set('units', self::$variable); |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | Event::on( |
| 96 | 96 | UnitsField::class, |
| 97 | 97 | 'craftQlGetFieldSchema', |
| 98 | - static function ($event) { |
|
| 98 | + static function($event) { |
|
| 99 | 99 | $field = $event->sender; |
| 100 | 100 | |
| 101 | 101 | if (!$field instanceof UnitsField) { |
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $object = $event->schema->createObjectType(ucfirst($field->handle) . 'Units'); |
|
| 105 | + $object = $event->schema->createObjectType(ucfirst($field->handle).'Units'); |
|
| 106 | 106 | $object->addFloatField('value'); |
| 107 | 107 | $object->addStringField('units'); |
| 108 | 108 | |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * @var int|float The minimum allowed number |
| 64 | 64 | */ |
| 65 | - public int|float $min; |
|
| 65 | + public int | float $min; |
|
| 66 | 66 | /** |
| 67 | 67 | * @var int|float|null The maximum allowed number |
| 68 | 68 | */ |
| 69 | - public int|null|float $max; |
|
| 69 | + public int | null | float $max; |
|
| 70 | 70 | /** |
| 71 | 71 | * @var int The number of digits allowed after the decimal point |
| 72 | 72 | */ |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | if (!empty($value)) { |
| 156 | 156 | // Handle a numeric value coming in (perhaps from a Number field) |
| 157 | 157 | if (is_numeric($value)) { |
| 158 | - $config['value'] = (float)$value; |
|
| 158 | + $config['value'] = (float) $value; |
|
| 159 | 159 | } elseif (is_string($value)) { |
| 160 | 160 | $config = Json::decodeIfJson($value); |
| 161 | 161 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | // Typecast it to a float |
| 167 | - $config['value'] = (float)$config['value']; |
|
| 167 | + $config['value'] = (float) $config['value']; |
|
| 168 | 168 | // Create and validate the model |
| 169 | 169 | $unitsData = new UnitsData($config); |
| 170 | 170 | if (!$unitsData->validate()) { |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'prefix' => Craft::$app->getView()->namespaceInputId(''), |
| 228 | 228 | ]; |
| 229 | 229 | $jsonVars = Json::encode($jsonVars); |
| 230 | - Craft::$app->getView()->registerJs("$('#{$namespacedId}-field').UnitsUnits(" . $jsonVars . ");"); |
|
| 230 | + Craft::$app->getView()->registerJs("$('#{$namespacedId}-field').UnitsUnits(".$jsonVars.");"); |
|
| 231 | 231 | |
| 232 | 232 | // Render the input template |
| 233 | 233 | return Craft::$app->getView()->renderTemplate( |