diff --git a/src/Copper/Copper.php b/src/Copper/Copper.php index cbc26f822d6a74b8963f5cf03c25250b2f1fa74a..61084709e152a4f655a2e63573bdb75a9ba6d8ea 100755 --- a/src/Copper/Copper.php +++ b/src/Copper/Copper.php @@ -55,15 +55,16 @@ class Copper /** * Create the instance of Copper. * - * @param float|string|null $value Number to be used in the formatter. - * @param int|null $style Style of formatter to use. - * @param string|null $locale Locale to use for the formatter. + * @param float|string|null $value Number to be used in the formatter. + * @param int|null $style Style of formatter to use. + * @param string|null $locale Locale to use for the formatter. + * * @return Copper Copper instance. */ public static function create(float|string|null $value = null, ?int $style = null, ?string $locale = null): Copper { - if (! self::$instance instanceof self) { - self::$instance = new self; + if (!self::$instance instanceof self) { + self::$instance = new self(); } if (false === is_null($value)) { @@ -84,7 +85,8 @@ class Copper /** * Format the number using DECIMAL. * - * @param int|null $precision Precision to use for formatter. + * @param int|null $precision Precision to use for formatter. + * * @return string|bool Formatted number. */ public static function decimal(?int $precision = null): string|bool @@ -102,7 +104,8 @@ class Copper /** * Format the number using CURRENCY. * - * @param string $iso The 3-letter ISO 4217 currency code indicating the currency to use. + * @param string $iso The 3-letter ISO 4217 currency code indicating the currency to use. + * * @return string|bool Formatted number. */ public static function currency(string $iso): string|bool @@ -145,7 +148,8 @@ class Copper /** * Format the number using CURRENCY_ACCOUNTING. * - * @param string $iso The 3-letter ISO 4217 currency code indicating the currency to use. + * @param string $iso The 3-letter ISO 4217 currency code indicating the currency to use. + * * @return string|bool Formatted number. */ public static function accounting(string $iso): string|bool @@ -174,12 +178,13 @@ class Copper /** * 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 @@ -195,7 +200,7 @@ class Copper $exponent = 0; if ($usePrefix) { - $exponent = (int) (floor(log10(abs($value)))); + $exponent = (int) floor(log10(abs($value))); if ($useThrees || $exponent >= 3) { $options = [ @@ -217,7 +222,8 @@ class Copper /** * Set the Locale. * - * @param string $locale Locale in which the number would be formatted. + * @param string $locale Locale in which the number would be formatted. + * * @return ?Copper Copper instance. */ public static function setLocale(string $locale): ?Copper @@ -241,7 +247,8 @@ class Copper /** * Set the Style. * - * @param int $style Style of the formatting. + * @param int $style Style of the formatting. + * * @return ?Copper Copper instance. */ public static function setStyle(int $style): ?Copper diff --git a/src/Copper/Enums/Prefix.php b/src/Copper/Enums/Prefix.php index 865efeba0f343f0a81e1b58d3dffb0ba5ccc0866..524f9b0e08edcf1df8bdbe159304dd166ae28066 100644 --- a/src/Copper/Enums/Prefix.php +++ b/src/Copper/Enums/Prefix.php @@ -36,30 +36,30 @@ enum Prefix: int { return match ($this) { self::QUETTA => 'Q', - self::RONNA => 'R', - self::YOTTA => 'Y', - self::ZETTA => 'Z', - self::EXA => 'E', - self::PETA => 'P', - self::TERA => 'T', - self::GIGA => 'G', - self::MEGA => 'M', - self::KILO => 'k', - self::HECTO => 'h', - self::DECA => 'da', - self::DECI => 'd', - self::CENTI => 'c', - self::MILLI => 'm', - self::MICRO => 'µ', - self::NANO => 'n', - self::PICO => 'p', - self::FEMTO => 'f', - self::ATTO => 'a', - self::ZEPTO => 'z', - self::YOCTO => 'y', - self::RONTO => 'r', + self::RONNA => 'R', + self::YOTTA => 'Y', + self::ZETTA => 'Z', + self::EXA => 'E', + self::PETA => 'P', + self::TERA => 'T', + self::GIGA => 'G', + self::MEGA => 'M', + self::KILO => 'k', + self::HECTO => 'h', + self::DECA => 'da', + self::DECI => 'd', + self::CENTI => 'c', + self::MILLI => 'm', + self::MICRO => 'µ', + self::NANO => 'n', + self::PICO => 'p', + self::FEMTO => 'f', + self::ATTO => 'a', + self::ZEPTO => 'z', + self::YOCTO => 'y', + self::RONTO => 'r', self::QUECTO => 'q', - self::BASE => '', + self::BASE => '', }; } diff --git a/src/Copper/Enums/Unit.php b/src/Copper/Enums/Unit.php index d591ee2163e0d15fc81609f045f5a3991c128b65..4245b8a126698fe0e05a0372642e7549ef500f5e 100644 --- a/src/Copper/Enums/Unit.php +++ b/src/Copper/Enums/Unit.php @@ -39,35 +39,35 @@ enum Unit: string public function name(): string { return match ($this) { - self::SECOND => 'Second', - self::METRE => 'Metre', - self::GRAM => 'Gram', - self::AMPERE => 'Ampere', - self::KELVIN => 'Kelvin', - self::MOLE => 'Mole', - self::CANDELA => 'Candela', - self::RADIAN => 'Radian', + self::SECOND => 'Second', + self::METRE => 'Metre', + self::GRAM => 'Gram', + self::AMPERE => 'Ampere', + self::KELVIN => 'Kelvin', + self::MOLE => 'Mole', + self::CANDELA => 'Candela', + self::RADIAN => 'Radian', self::STERADIAN => 'Steradian', - self::HERTZ => 'Hertz', - self::NEWTON => 'Newton', - self::PASCAL => 'Pascal', - self::JOULE => 'Joule', - self::WATT => 'Watt', - self::COULOMB => 'Coulomb', - self::VOLT => 'Volt', - self::FARAD => 'Farad', - self::OHM => 'Ohm', - self::SIEMENS => 'Siemens', - self::WEBER => 'Weber', - self::TESLA => 'Tesla', - self::HENRY => 'Henry', - self::CELSIUS => 'Celsius', - self::LUMEN => 'Lumen', - self::LUX => 'Lux', + self::HERTZ => 'Hertz', + self::NEWTON => 'Newton', + self::PASCAL => 'Pascal', + self::JOULE => 'Joule', + self::WATT => 'Watt', + self::COULOMB => 'Coulomb', + self::VOLT => 'Volt', + self::FARAD => 'Farad', + self::OHM => 'Ohm', + self::SIEMENS => 'Siemens', + self::WEBER => 'Weber', + self::TESLA => 'Tesla', + self::HENRY => 'Henry', + self::CELSIUS => 'Celsius', + self::LUMEN => 'Lumen', + self::LUX => 'Lux', self::BECQUEREL => 'Becquerel', - self::GRAY => 'Gray', - self::SIEVERT => 'Sievert', - self::KATAL => 'Katal', + self::GRAY => 'Gray', + self::SIEVERT => 'Sievert', + self::KATAL => 'Katal', }; } }