From f6da29b3940a9c7d0262a7c45935bbaefe4ea260 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 12 Feb 2025 11:08:57 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Copper/Copper.php | 17 ++++++++++------- src/Copper/Enums/Prefix.php | 8 +++++--- src/Copper/Enums/Unit.php | 6 +++--- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Copper/Copper.php b/src/Copper/Copper.php index 954279c..8d35208 100755 --- a/src/Copper/Copper.php +++ b/src/Copper/Copper.php @@ -183,10 +183,13 @@ public static function scientific(): string /** * Format the number using SI units and prefixes. - * @param Unit $unit SI Unit to display using. + * + * @param Unit $unit SI Unit to display using. + * * @parm bool $usePrefix Set whether to use prefixes. - * @param bool $useThrees Set whether to use only multiples of three in prefixes. - * @param int|null $precision Set the precision of the number. + * + * @param bool $useThrees Set whether to use only multiples of three in prefixes. + * @param int|null $precision Set the precision of the number. * @return string Formatted number. */ public static function unit(Unit $unit, bool $usePrefix = true, bool $useThrees = true, ?int $precision = null): string @@ -201,13 +204,13 @@ public static function unit(Unit $unit, bool $usePrefix = true, bool $useThrees $value = self::$value; $exponent = 0; - if($usePrefix) { - $exponent = (int) (floor(log10(abs($value)))); + if ($usePrefix) { + $exponent = (int) floor(log10(abs($value))); if ($useThrees || $exponent >= 3) { $options = [ (int) floor($exponent / 3) * 3, - (int) ceil($exponent / 3) * 3 + (int) ceil($exponent / 3) * 3, ]; $exponent = abs($exponent - $options[0]) < abs($options[1] - $exponent) @@ -218,7 +221,7 @@ public static function unit(Unit $unit, bool $usePrefix = true, bool $useThrees $value /= (10 ** $exponent); } - return self::$formatter->format($value) . ' ' . Prefix::from($exponent)->symbol() . $unit->value; + return self::$formatter->format($value).' '.Prefix::from($exponent)->symbol().$unit->value; } /** diff --git a/src/Copper/Enums/Prefix.php b/src/Copper/Enums/Prefix.php index 107068e..8daedef 100644 --- a/src/Copper/Enums/Prefix.php +++ b/src/Copper/Enums/Prefix.php @@ -32,8 +32,9 @@ enum Prefix: int case RONTO = -27; case QUECTO = -30; - public function symbol(): string { - return match($this) { + public function symbol(): string + { + return match ($this) { self::QUETTA => 'Q', self::RONNA => 'R', self::YOTTA => 'Y', @@ -62,7 +63,8 @@ public function symbol(): string { }; } - public function multipleOfThree(): bool { + public function multipleOfThree(): bool + { return ! abs(self::value) % 3; } } diff --git a/src/Copper/Enums/Unit.php b/src/Copper/Enums/Unit.php index 8dae176..d591ee2 100644 --- a/src/Copper/Enums/Unit.php +++ b/src/Copper/Enums/Unit.php @@ -36,9 +36,9 @@ enum Unit: string case SIEVERT = 'Sv'; case KATAL = 'kat'; - public function name(): string { - return match($this) - { + public function name(): string + { + return match ($this) { self::SECOND => 'Second', self::METRE => 'Metre', self::GRAM => 'Gram',