@@ -23,49 +23,49 @@ public function __construct(string $value)
23
23
24
24
public function add (NumberInterface $ addend ): self
25
25
{
26
- $ this ->value = bcadd ($ this ->value , (string ) $ addend , static ::PRECISION );
26
+ $ this ->value = \ bcadd ($ this ->value , (string ) $ addend , static ::PRECISION );
27
27
return $ this ;
28
28
}
29
29
30
30
public function sub (NumberInterface $ subtrahend ): self
31
31
{
32
- $ this ->value = bcsub ($ this ->value , (string ) $ subtrahend , static ::PRECISION );
32
+ $ this ->value = \ bcsub ($ this ->value , (string ) $ subtrahend , static ::PRECISION );
33
33
return $ this ;
34
34
}
35
35
36
36
public function mul (NumberInterface $ multiplicand ): self
37
37
{
38
- $ this ->value = bcmul ($ this ->value , (string ) $ multiplicand , static ::PRECISION );
38
+ $ this ->value = \ bcmul ($ this ->value , (string ) $ multiplicand , static ::PRECISION );
39
39
return $ this ;
40
40
}
41
41
42
42
public function div (NumberInterface $ divisor ): self
43
43
{
44
- $ this ->value = bcdiv ($ this ->value , (string ) $ divisor , static ::PRECISION );
44
+ $ this ->value = \ bcdiv ($ this ->value , (string ) $ divisor , static ::PRECISION );
45
45
return $ this ;
46
46
}
47
47
48
48
public function pow (NumberInterface $ exponent ): self
49
49
{
50
- $ this ->value = bcpow ($ this ->value , (string ) $ exponent , static ::PRECISION );
50
+ $ this ->value = \ bcpow ($ this ->value , (string ) $ exponent , static ::PRECISION );
51
51
return $ this ;
52
52
}
53
53
54
54
public function mod (NumberInterface $ divisor ): self
55
55
{
56
- $ this ->value = bcmod ($ this ->value , (string ) $ divisor , static ::PRECISION );
56
+ $ this ->value = \ bcmod ($ this ->value , (string ) $ divisor , static ::PRECISION );
57
57
return $ this ;
58
58
}
59
59
60
60
public function sqrt (): self
61
61
{
62
- $ this ->value = bcsqrt ($ this ->value , static ::PRECISION );
62
+ $ this ->value = \ bcsqrt ($ this ->value , static ::PRECISION );
63
63
return $ this ;
64
64
}
65
65
66
66
public function compare (NumberInterface $ operand ): int
67
67
{
68
- return bccomp ($ this ->value , (string ) $ operand , static ::PRECISION );
68
+ return \ bccomp ($ this ->value , (string ) $ operand , static ::PRECISION );
69
69
}
70
70
71
71
public function equals (NumberInterface $ operand ): bool
@@ -101,7 +101,7 @@ public function isInteger(): bool
101
101
return true ;
102
102
}
103
103
104
- return bccomp ($ parts [1 ], '0 ' ) === 0 ;
104
+ return \ bccomp ($ parts [1 ], '0 ' ) === 0 ;
105
105
}
106
106
107
107
public function __toString (): string
@@ -112,8 +112,12 @@ public function __toString(): string
112
112
protected function parseBcMathNumber (string $ string ): ?string
113
113
{
114
114
try {
115
- return bcadd ($ string , '0 ' , static ::PRECISION );
116
- } catch (\Throwable ) {
115
+ return \bcadd ($ string , '0 ' , static ::PRECISION );
116
+ } catch (\Throwable $ throwable ) {
117
+ if (!function_exists ('bcadd ' )) {
118
+ throw $ throwable ;
119
+ }
120
+
117
121
// not well-formed number
118
122
}
119
123
0 commit comments