Skip to content

Commit 2e9dabf

Browse files
committed
Cleanup.
1 parent c15f81f commit 2e9dabf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Decimal.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Decimal implements JsonSerializable, Stringable
5656
/**
5757
* decimal(10,6) => 6
5858
*/
59-
protected int $scale = 2;
59+
protected int $scale = 0;
6060

6161
/**
6262
* @param static|string|float|int $value
@@ -114,7 +114,7 @@ protected function normalizeValue(string $value): string
114114
/** @var string $value */
115115
$value = preg_replace(
116116
[
117-
'/^^([\-]?)(\.)(.*)$/', // omitted leading zero
117+
'/^^(-?)(\.)(.*)$/', // omitted leading zero
118118
'/^0+(.)(\..*)?$/', // multiple leading zeros
119119
'/^(\+(.*)|(-)(0))$/', // leading positive sign, tolerate minus zero too
120120
],
@@ -612,7 +612,7 @@ public function toScientific(): string
612612
}
613613

614614
$value = (string)$integralPart;
615-
if (strpos($value, '.') === false) {
615+
if (!str_contains($value, '.')) {
616616
$value .= '.';
617617
}
618618
$value .= $this->fractionalPart;
@@ -621,7 +621,7 @@ public function toScientific(): string
621621
// 00002
622622
// 20000
623623
$fractionalPart = $this->fractionalPart;
624-
while (substr($fractionalPart, 0, 1) === '0') {
624+
while (str_starts_with($fractionalPart, '0')) {
625625
$fractionalPart = substr($fractionalPart, 1);
626626
$exponent--;
627627
}
@@ -735,7 +735,7 @@ protected function setValue(string $value, ?int $scale): void
735735
return;
736736
}
737737

738-
if (strpos($value, '.') !== false) {
738+
if (str_contains($value, '.')) {
739739
$this->fromFloat($value);
740740

741741
return;
@@ -818,7 +818,7 @@ protected function fromScientific(string $value, ?int $scale): void
818818

819819
$pos = strlen($this->integralPart);
820820
$pos = strlen($this->integralPart);
821-
if (strpos($value, '.') !== false) {
821+
if (str_contains($value, '.')) {
822822
$pos++;
823823
}
824824
$this->fractionalPart = rtrim(substr($value, $pos), '.');

0 commit comments

Comments
 (0)