Test Failed
Pull Request — master (#118)
by Jordan
05:02
created
src/Samsara/Fermat/Types/Traits/Arithmetic/ArithmeticNativeTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
         $left = self::translateToNative($this);
23 23
         $right = self::translateToNative($num);
24 24
 
25
-        $value = $left + $right;
26
-        return (string)$value;
25
+        $value = $left+$right;
26
+        return (string) $value;
27 27
     }
28 28
 
29 29
     protected function subtractNative(DecimalInterface $num)
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
         $left = self::translateToNative($this);
32 32
         $right = self::translateToNative($num);
33 33
 
34
-        $value = $left - $right;
35
-        return (string)$value;
34
+        $value = $left-$right;
35
+        return (string) $value;
36 36
     }
37 37
 
38 38
     protected function multiplyNative(DecimalInterface $num)
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
         $left = self::translateToNative($this);
41 41
         $right = self::translateToNative($num);
42 42
 
43
-        $value = $left * $right;
44
-        return (string)$value;
43
+        $value = $left*$right;
44
+        return (string) $value;
45 45
     }
46 46
 
47 47
     protected function divideNative(DecimalInterface $num)
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
         $left = self::translateToNative($this);
50 50
         $right = self::translateToNative($num);
51 51
 
52
-        $value = $left / $right;
53
-        return (string)$value;
52
+        $value = $left/$right;
53
+        return (string) $value;
54 54
     }
55 55
 
56 56
     protected function powNative(DecimalInterface $num)
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
         $right = self::translateToNative($num);
60 60
 
61 61
         $value = pow($left, $right);
62
-        return (string)$value;
62
+        return (string) $value;
63 63
     }
64 64
 
65 65
     protected function sqrtNative()
66 66
     {
67 67
         $value = sqrt($this->asFloat());
68
-        return (string)$value;
68
+        return (string) $value;
69 69
     }
70 70
 
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/Samsara/Fermat/Types/NumberCollection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function sort(): NumberCollectionInterface
162 162
     {
163
-        $this->getCollection()->sort(function($left, $right){
163
+        $this->getCollection()->sort(function($left, $right) {
164 164
             return ArithmeticProvider::compare($left->getAsBaseTenRealNumber(), $right->getAsBaseTenRealNumber());
165 165
         });
166 166
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function getRandom(): NumberInterface
295 295
     {
296
-        $maxKey = $this->getCollection()->count() - 1;
296
+        $maxKey = $this->getCollection()->count()-1;
297 297
 
298 298
         $key = RandomProvider::randomInt(0, $maxKey, RandomProvider::MODE_SPEED)->asInt();
299 299
 
Please login to merge, or discard this patch.
src/Samsara/Fermat/Types/Traits/Decimal/ScaleTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $total = strlen($fractional);
106 106
         $fractional = ltrim($fractional, '0');
107 107
 
108
-        return ($total - strlen($fractional));
108
+        return ($total-strlen($fractional));
109 109
     }
110 110
 
111 111
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function isFloat(): bool
192 192
     {
193 193
 
194
-        return (bool)ArithmeticProvider::compare($this->getDecimalPart(), '0');
194
+        return (bool) ArithmeticProvider::compare($this->getDecimalPart(), '0');
195 195
 
196 196
     }
197 197
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             );
207 207
         }
208 208
 
209
-        return (float)$this->asReal();
209
+        return (float) $this->asReal();
210 210
 
211 211
     }
212 212
 
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RoundingProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $roundedPartString = $currentPart ? $decimalPart : $wholePart;
80 80
         $otherPart = $currentPart ? str_split($wholePart) : str_split($decimalPart);
81 81
         $baseLength = $currentPart ? strlen($decimalPart)-1 : strlen($wholePart);
82
-        $pos = $currentPart ? $places : $baseLength + $places;
82
+        $pos = $currentPart ? $places : $baseLength+$places;
83 83
         $carry = 0;
84 84
 
85 85
         if ($currentPart) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 break;
94 94
             }
95 95
 
96
-            $digit = (int)$roundedPart[$pos] + $carry;
96
+            $digit = (int) $roundedPart[$pos]+$carry;
97 97
 
98 98
             if ($carry == 0 && $digit == 5) {
99 99
                 static::$remainder = substr($roundedPartString, $pos+1);
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
 
104 104
             if ($pos == 0) {
105 105
                 if ($currentPart) {
106
-                    $nextDigit = (int)$otherPart[count($otherPart)-1];
106
+                    $nextDigit = (int) $otherPart[count($otherPart)-1];
107 107
                 } else {
108 108
                     $nextDigit = 0;
109 109
                 }
110 110
             } else {
111
-                $nextDigit = (int)$roundedPart[$pos-1];
111
+                $nextDigit = (int) $roundedPart[$pos-1];
112 112
             }
113 113
 
114 114
             if ($carry == 0) {
115
-                $carry = match (self::getRoundingMode()) {
115
+                $carry = match(self::getRoundingMode()) {
116 116
                     self::MODE_HALF_UP => self::roundHalfUp($digit),
117 117
                     self::MODE_HALF_DOWN => self::roundHalfDown($digit),
118 118
                     self::MODE_HALF_ODD => self::roundHalfOdd($digit, $nextDigit),
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         $remainder = self::remainderCheck();
240 240
 
241 241
         if ($early == 0) {
242
-            return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1;
242
+            return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1;
243 243
         } else {
244 244
             return $early == 1 ? 1 : 0;
245 245
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $remainder = self::remainderCheck();
252 252
 
253 253
         if ($early == 0) {
254
-            return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1;
254
+            return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1;
255 255
         } else {
256 256
             return $early == 1 ? 1 : 0;
257 257
         }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
         if ($early == 0 && !$remainder) {
303 303
             $val = self::$alt;
304
-            self::$alt = (int)!$val;
304
+            self::$alt = (int) !$val;
305 305
 
306 306
             return $val;
307 307
         } else {
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
             $rangeMax = 9;
320 320
         } else {
321 321
             $remainder = substr($remainder, 0, 3);
322
-            $target = (int)($digit.$remainder);
322
+            $target = (int) ($digit.$remainder);
323 323
             $rangeMin = 0;
324
-            $rangeMax = (int)str_repeat('9', strlen($remainder) + 1);
324
+            $rangeMax = (int) str_repeat('9', strlen($remainder)+1);
325 325
         }
326 326
 
327 327
         $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomProvider::MODE_SPEED)->asInt();
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RandomProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
      * @throws IncompatibleObjectState
29 29
      */
30 30
     public static function randomInt(
31
-        int|string|DecimalInterface $min,
32
-        int|string|DecimalInterface $max,
31
+        int | string | DecimalInterface $min,
32
+        int | string | DecimalInterface $max,
33 33
         #[ExpectedValues([self::MODE_ENTROPY, self::MODE_SPEED])]
34 34
         int $mode = self::MODE_ENTROPY
35 35
     ): ImmutableDecimal
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                     throw new OptionalExit(
107 107
                         'System error from random_bytes().',
108 108
                         'Ensure your system is configured correctly.',
109
-                        '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()
109
+                        '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()
110 110
                     );
111 111
                 }
112 112
             } elseif ($mode == self::MODE_SPEED) {
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
                      */
149 149
                     $entropyBytes = random_bytes($bytesNeeded->asInt());
150 150
                     $baseTwoBytes = '';
151
-                    for($i = 0; $i < strlen($entropyBytes); $i++){
152
-                        $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) );
151
+                    for ($i = 0; $i < strlen($entropyBytes); $i++) {
152
+                        $baseTwoBytes .= decbin(ord($entropyBytes[$i]));
153 153
                     }
154 154
                 } catch (Exception $e) {
155 155
                     throw new OptionalExit(
156 156
                         'System error from random_bytes().',
157 157
                         'Ensure your system is configured correctly.',
158
-                        '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()
158
+                        '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()
159 159
                     );
160 160
                 }
161 161
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
      * @throws IncompatibleObjectState
251 251
      */
252 252
     public static function randomReal(
253
-        int|string|DecimalInterface $min,
254
-        int|string|DecimalInterface $max,
253
+        int | string | DecimalInterface $min,
254
+        int | string | DecimalInterface $max,
255 255
         int $scale,
256 256
         #[ExpectedValues([self::MODE_ENTROPY, self::MODE_SPEED])]
257 257
         int $mode = self::MODE_ENTROPY
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                  * First we use string manipulation to extract the decimal portion as an integer value, the we right
369 369
                  * pad with zeroes to make sure that the entire scale is part of the valid result set.
370 370
                  */
371
-                $minDecimal = substr($min->getValue(), strpos($min->getValue(), '.') + 1);
371
+                $minDecimal = substr($min->getValue(), strpos($min->getValue(), '.')+1);
372 372
                 $minDecimal = str_pad($minDecimal, $scale, '0', STR_PAD_RIGHT);
373 373
             }
374 374
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
                  * We cannot take advantage of a more efficient check for the top end of the range, so the
378 378
                  * less than check is all we need.
379 379
                  */
380
-                $maxDecimal = str_pad('1', $scale + 1, '0', STR_PAD_RIGHT);
380
+                $maxDecimal = str_pad('1', $scale+1, '0', STR_PAD_RIGHT);
381 381
             } else {
382 382
                 /**
383 383
                  * The max value is guaranteed to have a decimal portion here since we excluded max being
Please login to merge, or discard this patch.
src/Samsara/Fermat/Renderer/Components/Operations/PowOperation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     private string $left;
14 14
     private string $right;
15 15
 
16
-    public function __construct(NumberInterface|ComponentInterface $left, NumberInterface|ComponentInterface $right)
16
+    public function __construct(NumberInterface | ComponentInterface $left, NumberInterface | ComponentInterface $right)
17 17
     {
18 18
 
19 19
         $this->left = ($left instanceof NumberInterface ? $left->getValue() : $left->getOutput());
Please login to merge, or discard this patch.