File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 10
10
use DivisionByZeroError ;
11
11
use InvalidArgumentException ;
12
12
use JsonSerializable ;
13
+ use Stringable ;
13
14
use TypeError ;
14
15
15
- class Decimal implements JsonSerializable
16
+ class Decimal implements JsonSerializable, Stringable
16
17
{
17
18
/**
18
19
* @var string
@@ -87,7 +88,7 @@ public function scale(): int
87
88
*/
88
89
protected function parseValue (object |string |float |int $ value ): string
89
90
{
90
- if (!(is_scalar ($ value ) || method_exists ( $ value, ' __toString ' ) )) {
91
+ if (!(is_scalar ($ value ) || $ value instanceof Stringable )) {
91
92
throw new InvalidArgumentException ('Invalid value ' );
92
93
}
93
94
@@ -818,14 +819,15 @@ protected function fromScientific(string $value, ?int $scale): void
818
819
} else {
819
820
$ this ->integralPart = bcmul ($ matches [2 ], bcpow ('10 ' , (string )$ exp ));
820
821
821
- $ pos = strlen ((string )$ this ->integralPart );
822
+ $ pos = strlen ($ this ->integralPart );
823
+ $ pos = strlen ($ this ->integralPart );
822
824
if (strpos ($ value , '. ' ) !== false ) {
823
825
$ pos ++;
824
826
}
825
827
$ this ->fractionalPart = rtrim (substr ($ value , $ pos ), '. ' );
826
828
827
829
if ($ scale !== null ) {
828
- $ this ->fractionalPart = str_pad ($ this ->fractionalPart , $ scale - strlen (( string ) $ this ->integralPart ), '0 ' );
830
+ $ this ->fractionalPart = str_pad ($ this ->fractionalPart , $ scale - strlen ($ this ->integralPart ), '0 ' );
829
831
}
830
832
}
831
833
}
You can’t perform that action at this time.
0 commit comments