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 1010use DivisionByZeroError ;
1111use InvalidArgumentException ;
1212use JsonSerializable ;
13+ use Stringable ;
1314use TypeError ;
1415
15- class Decimal implements JsonSerializable
16+ class Decimal implements JsonSerializable, Stringable
1617{
1718 /**
1819 * @var string
@@ -87,7 +88,7 @@ public function scale(): int
8788 */
8889 protected function parseValue (object |string |float |int $ value ): string
8990 {
90- if (!(is_scalar ($ value ) || method_exists ( $ value, ' __toString ' ) )) {
91+ if (!(is_scalar ($ value ) || $ value instanceof Stringable )) {
9192 throw new InvalidArgumentException ('Invalid value ' );
9293 }
9394
@@ -818,14 +819,15 @@ protected function fromScientific(string $value, ?int $scale): void
818819 } else {
819820 $ this ->integralPart = bcmul ($ matches [2 ], bcpow ('10 ' , (string )$ exp ));
820821
821- $ pos = strlen ((string )$ this ->integralPart );
822+ $ pos = strlen ($ this ->integralPart );
823+ $ pos = strlen ($ this ->integralPart );
822824 if (strpos ($ value , '. ' ) !== false ) {
823825 $ pos ++;
824826 }
825827 $ this ->fractionalPart = rtrim (substr ($ value , $ pos ), '. ' );
826828
827829 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 ' );
829831 }
830832 }
831833 }
You can’t perform that action at this time.
0 commit comments