diff --git a/src/Currencies/USD.php b/src/Currencies/USD.php index b9d607f..bfbbf45 100644 --- a/src/Currencies/USD.php +++ b/src/Currencies/USD.php @@ -15,5 +15,5 @@ class USD extends Currency protected int $displayDecimals = 2; protected int $rounding = 2; protected string $prefix = '$'; - protected bool $deleteTrailingDecimalZeros = false; + protected bool $trimTrailingDecimalZeros = false; } diff --git a/src/Currency.php b/src/Currency.php index 9329c11..97d0bdf 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -41,7 +41,7 @@ class Currency implements Arrayable, JsonSerializable protected int $rounding; /** Setting to decide if trailing decimal zeros should be removed for when calling formatted(). */ - protected bool $deleteTrailingDecimalZeros; + protected bool $trimTrailingDecimalZeros; /** Create a new Currency instance. */ public function __construct( @@ -55,7 +55,7 @@ class Currency implements Arrayable, JsonSerializable int $rounding = null, string $decimalSeparator = null, string $thousandsSeparator = null, - bool $deleteTrailingDecimalZeros = null, + bool $trimTrailingDecimalZeros = null, ) { $this->code = $code ?? $this->code ?? ''; $this->name = $name ?? $this->name ?? ''; @@ -67,7 +67,7 @@ class Currency implements Arrayable, JsonSerializable $this->decimalSeparator = $decimalSeparator ?? $this->decimalSeparator ?? '.'; $this->thousandsSeparator = $thousandsSeparator ?? $this->thousandsSeparator ?? ','; $this->rounding = $rounding ?? $this->rounding ?? $this->mathDecimals; - $this->deleteTrailingDecimalZeros = $deleteTrailingDecimalZeros ?? $this->deleteTrailingDecimalZeros ?? false; + $this->trimTrailingDecimalZeros = $trimTrailingDecimalZeros ?? $this->trimTrailingDecimalZeros ?? false; $this->check(); } @@ -139,9 +139,9 @@ class Currency implements Arrayable, JsonSerializable } /** Get the setting for how trailing decimal zeroes should be handled. */ - public function deleteTrailingDecimalZeros(): bool + public function trimTrailingDecimalZeros(): bool { - return $this->deleteTrailingDecimalZeros; + return $this->trimTrailingDecimalZeros; } /** Convert the currency to a string (returns the code). */ @@ -164,7 +164,7 @@ class Currency implements Arrayable, JsonSerializable 'rounding' => $this->rounding, 'decimalSeparator' => $this->decimalSeparator, 'thousandsSeparator' => $this->thousandsSeparator, - 'deleteTrailingDecimalZeros' => $this->deleteTrailingDecimalZeros, + 'trimTrailingDecimalZeros' => $this->trimTrailingDecimalZeros, ]; } diff --git a/src/PriceFormatter.php b/src/PriceFormatter.php index 89fc6a9..803d147 100644 --- a/src/PriceFormatter.php +++ b/src/PriceFormatter.php @@ -23,7 +23,7 @@ class PriceFormatter $currency->thousandsSeparator(), ); - if ($currency->deleteTrailingDecimalZeros()) { + if ($currency->trimTrailingDecimalZeros()) { // Remove trailing zeros from price $decimal = rtrim($decimal, '0'); // If there is no more decimal values, remove the trailing decimal separator as well diff --git a/tests/Currencies/CZK.php b/tests/Currencies/CZK.php index 75ccac4..0954472 100644 --- a/tests/Currencies/CZK.php +++ b/tests/Currencies/CZK.php @@ -15,5 +15,5 @@ class CZK extends Currency protected string $thousandsSeparator = '.'; protected int $rounding = 2; protected string $suffix = ' Kč'; - protected bool $deleteTrailingDecimalZeros = false; + protected bool $trimTrailingDecimalZeros = false; } diff --git a/tests/Currencies/EUR.php b/tests/Currencies/EUR.php index d4c9719..22cfd59 100644 --- a/tests/Currencies/EUR.php +++ b/tests/Currencies/EUR.php @@ -13,5 +13,5 @@ class EUR extends Currency protected int $displayDecimals = 2; protected int $rounding = 0; protected string $suffix = ' €'; - protected bool $deleteTrailingDecimalZeros = false; + protected bool $trimTrailingDecimalZeros = false; } diff --git a/tests/Currencies/SEK.php b/tests/Currencies/SEK.php index c647ec0..7d13337 100644 --- a/tests/Currencies/SEK.php +++ b/tests/Currencies/SEK.php @@ -13,5 +13,5 @@ class SEK extends Currency protected int $displayDecimals = 2; protected int $rounding = 0; protected string $suffix = ' kr'; - protected bool $deleteTrailingDecimalZeros = true; + protected bool $trimTrailingDecimalZeros = true; } diff --git a/tests/Pest/CurrencyTest.php b/tests/Pest/CurrencyTest.php index 766c9e8..4d917bd 100644 --- a/tests/Pest/CurrencyTest.php +++ b/tests/Pest/CurrencyTest.php @@ -28,7 +28,7 @@ test('currencies can be serialized to JSON', function () { 'rounding' => 2, 'decimalSeparator' => ',', 'thousandsSeparator' => '.', - 'deleteTrailingDecimalZeros' => false, + 'trimTrailingDecimalZeros' => false, ]); });