@@ -56,7 +56,7 @@ class Decimal implements JsonSerializable, Stringable
56
56
/**
57
57
* decimal(10,6) => 6
58
58
*/
59
- protected int $ scale = 2 ;
59
+ protected int $ scale = 0 ;
60
60
61
61
/**
62
62
* @param static|string|float|int $value
@@ -114,7 +114,7 @@ protected function normalizeValue(string $value): string
114
114
/** @var string $value */
115
115
$ value = preg_replace (
116
116
[
117
- '/^^([\-] ?)(\.)(.*)$/ ' , // omitted leading zero
117
+ '/^^(- ?)(\.)(.*)$/ ' , // omitted leading zero
118
118
'/^0+(.)(\..*)?$/ ' , // multiple leading zeros
119
119
'/^(\+(.*)|(-)(0))$/ ' , // leading positive sign, tolerate minus zero too
120
120
],
@@ -612,7 +612,7 @@ public function toScientific(): string
612
612
}
613
613
614
614
$ value = (string )$ integralPart ;
615
- if (strpos ($ value , '. ' ) === false ) {
615
+ if (! str_contains ($ value , '. ' )) {
616
616
$ value .= '. ' ;
617
617
}
618
618
$ value .= $ this ->fractionalPart ;
@@ -621,7 +621,7 @@ public function toScientific(): string
621
621
// 00002
622
622
// 20000
623
623
$ fractionalPart = $ this ->fractionalPart ;
624
- while (substr ($ fractionalPart , 0 , 1 ) === '0 ' ) {
624
+ while (str_starts_with ($ fractionalPart , '0 ' ) ) {
625
625
$ fractionalPart = substr ($ fractionalPart , 1 );
626
626
$ exponent --;
627
627
}
@@ -735,7 +735,7 @@ protected function setValue(string $value, ?int $scale): void
735
735
return ;
736
736
}
737
737
738
- if (strpos ($ value , '. ' ) !== false ) {
738
+ if (str_contains ($ value , '. ' )) {
739
739
$ this ->fromFloat ($ value );
740
740
741
741
return ;
@@ -818,7 +818,7 @@ protected function fromScientific(string $value, ?int $scale): void
818
818
819
819
$ pos = strlen ($ this ->integralPart );
820
820
$ pos = strlen ($ this ->integralPart );
821
- if (strpos ($ value , '. ' ) !== false ) {
821
+ if (str_contains ($ value , '. ' )) {
822
822
$ pos ++;
823
823
}
824
824
$ this ->fractionalPart = rtrim (substr ($ value , $ pos ), '. ' );
0 commit comments