1010
1111namespace MaplePHP \DTO \Format ;
1212
13+ use NumberFormatter ;
14+
1315final class Num extends FormatAbstract implements FormatInterface
1416{
1517 private static $ numFormatter ;
@@ -22,14 +24,17 @@ final class Num extends FormatAbstract implements FormatInterface
2224 */
2325 public static function value (mixed $ value ): FormatInterface
2426 {
25- $ inst = new static ($ value );
26- return $ inst ;
27+ return new static ($ value );
2728 }
2829
29- public static function numFormatter ()
30+ /**
31+ * Add number format for currency
32+ * @return NumberFormatter
33+ */
34+ public static function numFormatter (): NumberFormatter
3035 {
3136 if (is_null (self ::$ numFormatter )) {
32- self ::$ numFormatter = new \ NumberFormatter ("sv_SE " , \ NumberFormatter::CURRENCY );
37+ self ::$ numFormatter = new NumberFormatter ("sv_SE " , NumberFormatter::CURRENCY );
3338 }
3439 return self ::$ numFormatter ;
3540 }
@@ -148,7 +153,7 @@ public function toBytes(): self
148153 }
149154
150155 /**
151- * Convert number to a currence (e.g. 1000 = 1.000,00 kr)
156+ * Convert number to a currency (e.g. 1000 = 1.000,00 kr)
152157 * @param string $currency SEK, EUR
153158 * @param int|integer $decimals
154159 * @return FormatInterface
@@ -157,7 +162,6 @@ public function currency(string $currency, int $decimals = 2): FormatInterface
157162 {
158163 self ::numFormatter ()->setAttribute (self ::$ numFormatter ::ROUNDING_MODE , $ decimals );
159164 self ::numFormatter ()->setAttribute (self ::$ numFormatter ::FRACTION_DIGITS , $ decimals );
160-
161165 // Traverse back to string
162166 return Str::value (self ::numFormatter ()->formatCurrency ($ this ->float ()->get (), $ currency ));
163167 }
0 commit comments