Passed
Push — master ( 1d9e63...f4e7c0 )
by Jordan
19:39 queued 13:26
created
src/Samsara/Fermat/Types/Traits/Arithmetic/ArithmeticSelectionTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     protected function addSelector(DecimalInterface $num)
142 142
     {
143
-        return match ($this->calcMode) {
143
+        return match($this->calcMode) {
144 144
             Selectable::CALC_MODE_PRECISION => $this->addScale($num),
145 145
             Selectable::CALC_MODE_NATIVE => $this->addNative($num),
146 146
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['add']}($num),
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     protected function subtractSelector(DecimalInterface $num)
151 151
     {
152
-        return match ($this->calcMode) {
152
+        return match($this->calcMode) {
153 153
             Selectable::CALC_MODE_PRECISION => $this->subtractScale($num),
154 154
             Selectable::CALC_MODE_NATIVE => $this->subtractNative($num),
155 155
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['subtract']}($num),
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     protected function multiplySelector(DecimalInterface $num)
160 160
     {
161
-        return match ($this->calcMode) {
161
+        return match($this->calcMode) {
162 162
             Selectable::CALC_MODE_PRECISION => $this->multiplyScale($num),
163 163
             Selectable::CALC_MODE_NATIVE => $this->multiplyNative($num),
164 164
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['multiply']}($num),
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
     protected function divideSelector(DecimalInterface $num, int $scale)
169 169
     {
170
-        return match ($this->calcMode) {
170
+        return match($this->calcMode) {
171 171
             Selectable::CALC_MODE_PRECISION => $this->divideScale($num, $scale),
172 172
             Selectable::CALC_MODE_NATIVE => $this->divideNative($num),
173 173
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['divide']}($num, $scale),
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
     protected function powSelector(DecimalInterface $num)
178 178
     {
179
-        return match ($this->calcMode) {
179
+        return match($this->calcMode) {
180 180
             Selectable::CALC_MODE_PRECISION => $this->powScale($num),
181 181
             Selectable::CALC_MODE_NATIVE => $this->powNative($num),
182 182
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['pow']}($num),
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
     protected function sqrtSelector(int $scale)
187 187
     {
188
-        return match ($this->calcMode) {
188
+        return match($this->calcMode) {
189 189
             Selectable::CALC_MODE_PRECISION => $this->sqrtScale($scale),
190 190
             Selectable::CALC_MODE_NATIVE => $this->sqrtNative(),
191 191
             default => $this->{$this->modeRegister[Selectable::CALC_MODE_FALLBACK]['sqrt']}($scale),
Please login to merge, or discard this patch.
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/Traits/Decimal/ScaleTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
                 $rounded = $whole.'.';
57 57
 
58
-                for ($i = 0;$i < $decimals;$i++) {
58
+                for ($i = 0; $i < $decimals; $i++) {
59 59
                     $rounded .= $fractionalArr[$i];
60 60
                 }
61 61
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $total = strlen($fractional);
144 144
         $fractional = ltrim($fractional, '0');
145 145
 
146
-        return ($total - strlen($fractional));
146
+        return ($total-strlen($fractional));
147 147
     }
148 148
 
149 149
     /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     public function isFloat(): bool
230 230
     {
231 231
 
232
-        return (bool)ArithmeticProvider::compare($this->getDecimalPart(), '0');
232
+        return (bool) ArithmeticProvider::compare($this->getDecimalPart(), '0');
233 233
 
234 234
     }
235 235
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             );
245 245
         }
246 246
 
247
-        return (float)$this->asReal();
247
+        return (float) $this->asReal();
248 248
 
249 249
     }
250 250
 
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/Provider/RandomProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
      */
31 31
     #[Pure]
32 32
     public static function randomInt(
33
-        int|string|DecimalInterface $min,
34
-        int|string|DecimalInterface $max,
33
+        int | string | DecimalInterface $min,
34
+        int | string | DecimalInterface $max,
35 35
         #[ExpectedValues([self::MODE_ENTROPY, self::MODE_SPEED])]
36 36
         int $mode = self::MODE_ENTROPY
37 37
     ): ImmutableDecimal
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     throw new OptionalExit(
109 109
                         'System error from random_bytes().',
110 110
                         'Ensure your system is configured correctly.',
111
-                        '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()
111
+                        '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()
112 112
                     );
113 113
                 }
114 114
             } elseif ($mode == self::MODE_SPEED) {
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
                      */
151 151
                     $entropyBytes = random_bytes($bytesNeeded->asInt());
152 152
                     $baseTwoBytes = '';
153
-                    for($i = 0; $i < strlen($entropyBytes); $i++){
154
-                        $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) );
153
+                    for ($i = 0; $i < strlen($entropyBytes); $i++) {
154
+                        $baseTwoBytes .= decbin(ord($entropyBytes[$i]));
155 155
                     }
156 156
                 } catch (Exception $e) {
157 157
                     throw new OptionalExit(
158 158
                         'System error from random_bytes().',
159 159
                         'Ensure your system is configured correctly.',
160
-                        '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()
160
+                        '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()
161 161
                     );
162 162
                 }
163 163
 
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
      */
255 255
     #[Pure]
256 256
     public static function randomReal(
257
-        int|string|DecimalInterface $min,
258
-        int|string|DecimalInterface $max,
257
+        int | string | DecimalInterface $min,
258
+        int | string | DecimalInterface $max,
259 259
         int $scale,
260 260
         #[ExpectedValues([self::MODE_ENTROPY, self::MODE_SPEED])]
261 261
         int $mode = self::MODE_ENTROPY
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
                  * First we use string manipulation to extract the decimal portion as an integer value, the we right
373 373
                  * pad with zeroes to make sure that the entire scale is part of the valid result set.
374 374
                  */
375
-                $minDecimal = substr($min->getValue(), strpos($min->getValue(), '.') + 1);
375
+                $minDecimal = substr($min->getValue(), strpos($min->getValue(), '.')+1);
376 376
                 $minDecimal = str_pad($minDecimal, $scale, '0', STR_PAD_RIGHT);
377 377
             }
378 378
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                  * We cannot take advantage of a more efficient check for the top end of the range, so the
382 382
                  * less than check is all we need.
383 383
                  */
384
-                $maxDecimal = str_pad('1', $scale + 1, '0', STR_PAD_RIGHT);
384
+                $maxDecimal = str_pad('1', $scale+1, '0', STR_PAD_RIGHT);
385 385
             } else {
386 386
                 /**
387 387
                  * The max value is guaranteed to have a decimal portion here since we excluded max being
Please login to merge, or discard this patch.