From 8bdf0d1a2bc9ecb65b70b454c0743459b2691d05 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Wed, 9 Mar 2022 12:49:00 +0530 Subject: [PATCH] refactor: improve code readability --- src/Money.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Money.php b/src/Money.php index 94dff7b..886fdcd 100644 --- a/src/Money.php +++ b/src/Money.php @@ -36,7 +36,7 @@ final class Money implements JsonSerializable, Arrayable, Wireable public static function fromDecimal(float $decimal, Currency|string $currency = null): self { return new static( - (int) round($decimal * 10 ** currency($currency)->mathDecimals()), + (int) round($decimal * pow(10, currency($currency)->mathDecimals())), currency($currency) ); } @@ -154,7 +154,7 @@ final class Money implements JsonSerializable, Arrayable, Wireable /** Get the decimal representation of the value. */ public function decimal(): float { - return $this->value / 10 ** $this->currency->mathDecimals(); + return $this->value / pow(10, $this->currency->mathDecimals()); } /** Format the value. */ @@ -228,7 +228,7 @@ final class Money implements JsonSerializable, Arrayable, Wireable return $this ->divideBy($this->currency->rate()) - ->divideBy(10 ** $mathDecimalDifference) + ->divideBy(pow(10, $mathDecimalDifference)) ->value(); } @@ -240,7 +240,7 @@ final class Money implements JsonSerializable, Arrayable, Wireable $mathDecimalDifference = $newCurrency->mathDecimals() - currencies()->getDefault()->mathDecimals(); return new static( - (int) round($this->valueInDefaultCurrency() * $newCurrency->rate() * 10 ** $mathDecimalDifference, 0), + (int) round($this->valueInDefaultCurrency() * $newCurrency->rate() * pow(10, $mathDecimalDifference), 0), $currency ); }