@@ -26,7 +26,7 @@ |
||
26 | 26 | $remainder = substr($remainder, 0, 3); |
27 | 27 | $target = (int)($digit.$remainder); |
28 | 28 | $rangeMin = 0; |
29 | - $rangeMax = (int)str_repeat('9', strlen($remainder) + 1); |
|
29 | + $rangeMax = (int)str_repeat('9', strlen($remainder)+1); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomMode::Speed)->asInt(); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $remainder = $this->remainderCheck(); |
18 | 18 | |
19 | 19 | if ($early == 0) { |
20 | - return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1; |
|
20 | + return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1; |
|
21 | 21 | } else { |
22 | 22 | return $early == 1 ? 1 : 0; |
23 | 23 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $remainder = $this->remainderCheck(); |
18 | 18 | |
19 | 19 | if ($early == 0) { |
20 | - return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1; |
|
20 | + return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1; |
|
21 | 21 | } else { |
22 | 22 | return $early == 1 ? 1 : 0; |
23 | 23 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @throws IntegrityConstraint |
35 | 35 | */ |
36 | 36 | public static function randomInt( |
37 | - int|string|DecimalInterface $min, |
|
38 | - int|string|DecimalInterface $max, |
|
37 | + int | string | DecimalInterface $min, |
|
38 | + int | string | DecimalInterface $max, |
|
39 | 39 | RandomMode $mode = RandomMode::Entropy, |
40 | 40 | ?int $seed = null |
41 | 41 | ): ImmutableDecimal |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | */ |
121 | 121 | $entropyBytes = $randomizer->getBytes($bytesNeeded->asInt()); |
122 | 122 | $baseTwoBytes = ''; |
123 | - for($i = 0; $i < strlen($entropyBytes); $i++){ |
|
124 | - $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) ); |
|
123 | + for ($i = 0;$i < strlen($entropyBytes);$i++) { |
|
124 | + $baseTwoBytes .= decbin(ord($entropyBytes[$i])); |
|
125 | 125 | } |
126 | 126 | } catch (Exception $e) { |
127 | 127 | throw new OptionalExit( |
128 | 128 | 'System error from random_bytes().', |
129 | 129 | 'Ensure your system is configured correctly.', |
130 | - 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: ' . $e->getMessage() |
|
130 | + 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: '.$e->getMessage() |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $randomizer = self::getRandomizer($mode); |
186 | 186 | |
187 | 187 | $result = '0.'; |
188 | - for ($i = 0; $i < $scale; $i++) { |
|
188 | + for ($i = 0;$i < $scale;$i++) { |
|
189 | 189 | $result .= $randomizer->getInt(0, 9); |
190 | 190 | } |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @throws RandomException |
202 | 202 | */ |
203 | 203 | public static function randomReal( |
204 | - int|string|DecimalInterface $min, |
|
205 | - int|string|DecimalInterface $max, |
|
204 | + int | string | DecimalInterface $min, |
|
205 | + int | string | DecimalInterface $max, |
|
206 | 206 | int $scale, |
207 | 207 | RandomMode $mode = RandomMode::Entropy |
208 | 208 | ): ImmutableDecimal |
@@ -219,11 +219,11 @@ discard block |
||
219 | 219 | return $min; |
220 | 220 | } |
221 | 221 | |
222 | - $intScale = $scale + 2; |
|
222 | + $intScale = $scale+2; |
|
223 | 223 | |
224 | 224 | $range = $max->subtract($min); |
225 | 225 | |
226 | - $intScale = $intScale + $range->numberOfTotalDigits(); |
|
226 | + $intScale = $intScale+$range->numberOfTotalDigits(); |
|
227 | 227 | |
228 | 228 | $randomDecimal = self::randomDecimal($intScale, $mode); |
229 | 229 |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $roundedPartString = $wholePart; |
141 | 141 | $otherPart = str_split($decimalPart); |
142 | 142 | $baseLength = strlen($wholePart); |
143 | - $pos = ($absPlaces >= $baseLength) ? 0 : $baseLength + $places; |
|
143 | + $pos = ($absPlaces >= $baseLength) ? 0 : $baseLength+$places; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return [ |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | bool $currentPart |
215 | 215 | ): array |
216 | 216 | { |
217 | - $digit = (int)$roundedPart[$pos] + $carry; |
|
217 | + $digit = (int)$roundedPart[$pos]+$carry; |
|
218 | 218 | |
219 | 219 | if ($carry == 0 && $digit == 5 && strlen($roundedPartString) > $pos+1) { |
220 | 220 | $remainder = substr($roundedPartString, $pos+1); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $number = str_replace('-', '-'.$currency->value, $number); |
34 | 34 | $number = str_replace('+', '+'.$currency->value, $number); |
35 | 35 | } else { |
36 | - $number = $currency->value . $number; |
|
36 | + $number = $currency->value.$number; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $number; |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $number = $wholePart; |
72 | 72 | |
73 | 73 | if ($decimalPart) { |
74 | - $number .= self::getRadixCharacter($format) . $decimalPart; |
|
74 | + $number .= self::getRadixCharacter($format).$decimalPart; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | if (str_contains($posNegChar, '\N')) { |
79 | 79 | $number = str_replace('\N', $number, $posNegChar); |
80 | 80 | } else { |
81 | - $number = $posNegChar . $number; |
|
81 | + $number = $posNegChar.$number; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $number; |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | if ($wholeSizeNonZero) { |
108 | 108 | $exponent = $wholeSizeNonZero; |
109 | 109 | $exponent -= 1; |
110 | - $mantissa = substr($wholePart, 0, 1) . '.' . substr($wholePart, 1) . $decimalPart; |
|
110 | + $mantissa = substr($wholePart, 0, 1).'.'.substr($wholePart, 1).$decimalPart; |
|
111 | 111 | } else { |
112 | - $exponent = strlen($decimalPart) - $decimalSizeNonZero; |
|
112 | + $exponent = strlen($decimalPart)-$decimalSizeNonZero; |
|
113 | 113 | $exponent += 1; |
114 | - $mantissa = substr($decimalPart, $exponent-1, 1) . '.' . substr($decimalPart, $exponent); |
|
114 | + $mantissa = substr($decimalPart, $exponent-1, 1).'.'.substr($decimalPart, $exponent); |
|
115 | 115 | $exponent *= -1; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $mantissa = rtrim($mantissa, '0'); |
119 | 119 | |
120 | - return $negative . $mantissa . 'E' . $exponent . $imaginary; |
|
120 | + return $negative.$mantissa.'E'.$exponent.$imaginary; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | $formatted = ''; |
138 | 138 | |
139 | 139 | for ($i = 0;$i < count($numberArr);$i++) { |
140 | - $j = $i + 1; |
|
140 | + $j = $i+1; |
|
141 | 141 | |
142 | 142 | $formatted = $numberArr[$i].$formatted; |
143 | 143 | |
144 | 144 | if ($grouping == NumberGrouping::Standard) { |
145 | - if ($j % 3 == 0 && array_key_exists($i+1, $numberArr)) { |
|
145 | + if ($j%3 == 0 && array_key_exists($i+1, $numberArr)) { |
|
146 | 146 | $formatted = self::getDelimiterCharacter($format).$formatted; |
147 | 147 | } |
148 | 148 | } elseif ($grouping == NumberGrouping::Indian) { |
149 | 149 | if ($j == 3 && array_key_exists($i+1, $numberArr)) { |
150 | 150 | $formatted = self::getDelimiterCharacter($format).$formatted; |
151 | - } elseif (($j - 3) % 2 == 0 && ($j - 3) > 0 && array_key_exists($i+1, $numberArr)) { |
|
151 | + } elseif (($j-3)%2 == 0 && ($j-3) > 0 && array_key_exists($i+1, $numberArr)) { |
|
152 | 152 | $formatted = self::getDelimiterCharacter($format).$formatted; |
153 | 153 | } |
154 | 154 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | return self::$pi->truncateToScale($digits)->getValue(NumberBase::Ten); |
38 | 38 | } |
39 | 39 | |
40 | - $internalScale = ($digits*2) + 10; |
|
40 | + $internalScale = ($digits*2)+10; |
|
41 | 41 | |
42 | 42 | $C = Numbers::make(Numbers::IMMUTABLE, '10005', $internalScale)->setMode(CalcMode::Precision)->sqrt($internalScale)->multiply(426880); |
43 | 43 | $M = Numbers::make(Numbers::IMMUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); |
44 | 44 | $L = Numbers::make(Numbers::IMMUTABLE, '13591409', $internalScale)->setMode(CalcMode::Precision); |
45 | 45 | $K = Numbers::make(Numbers::IMMUTABLE, '6', $internalScale)->setMode(CalcMode::Precision); |
46 | 46 | $X = Numbers::make(Numbers::IMMUTABLE, '1')->setMode(CalcMode::Precision); |
47 | - $sum = Numbers::make(Numbers::MUTABLE,'0', $internalScale + 2)->setMode(CalcMode::Precision); |
|
47 | + $sum = Numbers::make(Numbers::MUTABLE, '0', $internalScale+2)->setMode(CalcMode::Precision); |
|
48 | 48 | $termNum = 0; |
49 | 49 | $one = Numbers::makeOne($internalScale)->setMode(CalcMode::Precision); |
50 | 50 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | return self::$e->truncateToScale($digits)->getValue(NumberBase::Ten); |
97 | 97 | } |
98 | 98 | |
99 | - $internalScale = $digits + 3; |
|
99 | + $internalScale = $digits+3; |
|
100 | 100 | |
101 | 101 | $one = Numbers::makeOne($internalScale+5)->setMode(CalcMode::Precision); |
102 | 102 | $denominator = Numbers::make(Numbers::MUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return ImmutableDecimal|MutableDecimal|NumberInterface|ImmutableDecimal[]|MutableDecimal[]|NumberInterface[] |
115 | 115 | * @throws IntegrityConstraint |
116 | 116 | */ |
117 | - public static function makeOrDont(string|object $type, mixed $value, ?int $scale = null, NumberBase $base = NumberBase::Ten) |
|
117 | + public static function makeOrDont(string | object $type, mixed $value, ?int $scale = null, NumberBase $base = NumberBase::Ten) |
|
118 | 118 | { |
119 | 119 | |
120 | 120 | if (is_object($value)) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | if ($scale > 100) { |
239 | - $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale+2), $scale + 2); |
|
239 | + $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale+2), $scale+2); |
|
240 | 240 | /** @var ImmutableDecimal */ |
241 | 241 | return $pi->multiply(2)->truncateToScale($scale); |
242 | 242 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function subtract(VectorInterface $vector): VectorInterface; |
14 | 14 | |
15 | - public function multiply(int|float|string|NumberInterface|VectorInterface $value): NumberInterface|VectorInterface; |
|
15 | + public function multiply(int | float | string | NumberInterface | VectorInterface $value): NumberInterface | VectorInterface; |
|
16 | 16 | |
17 | 17 | public function multiplyScalar(NumberInterface $number): VectorInterface; |
18 | 18 |