Test Failed
Pull Request — master (#127)
by Jordan
06:34
created
src/Samsara/Fermat/Provider/TrigonometryProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
     public static function radiansToDegrees($radians)
22 22
     {
23 23
         $radians = Numbers::makeOrDont(Numbers::IMMUTABLE, $radians);
24
-        $pi = Numbers::makePi($radians->getScale() + 2);
24
+        $pi = Numbers::makePi($radians->getScale()+2);
25 25
         
26
-        return $radians->multiply(180)->divide($pi, $radians->getScale() + 2)->round($radians->getScale() - 2)->getValue(NumberBase::Ten);
26
+        return $radians->multiply(180)->divide($pi, $radians->getScale()+2)->round($radians->getScale()-2)->getValue(NumberBase::Ten);
27 27
     }
28 28
 
29 29
     /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public static function degreesToRadians($degrees)
36 36
     {
37 37
         $degrees = Numbers::makeOrDont(Numbers::IMMUTABLE, $degrees);
38
-        $pi = Numbers::makePi($degrees->getScale() + 1);
38
+        $pi = Numbers::makePi($degrees->getScale()+1);
39 39
 
40 40
         return $degrees->multiply($pi)->divide(180)->round($degrees->getScale())->getValue(NumberBase::Ten);
41 41
     }
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/SequenceProvider.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -20,57 +20,57 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
     const EULER_ZIGZAG = [
23
-        '1',                                                        // 0
24
-        '1',                                                        // 1
25
-        '1',                                                        // 2
26
-        '2',                                                        // 3
27
-        '5',                                                        // 4
28
-        '16',                                                       // 5
29
-        '61',                                                       // 6
30
-        '272',                                                      // 7
31
-        '1385',                                                     // 8
32
-        '7936',                                                     // 9
33
-        '50521',                                                    // 10
34
-        '353792',                                                   // 11
35
-        '2702765',                                                  // 12
36
-        '22368256',                                                 // 13
37
-        '199360981',                                                // 14
38
-        '1903757312',                                               // 15
39
-        '19391512145',                                              // 16
40
-        '209865342976',                                             // 17
41
-        '2404879675441',                                            // 18
42
-        '29088885112832',                                           // 19
43
-        '370371188237525',                                          // 20
44
-        '4951498053124096',                                         // 21
45
-        '69348874393137901',                                        // 22
46
-        '1015423886506852352',                                      // 23
47
-        '15514534163557086905',                                     // 24
48
-        '246921480190207983616',                                    // 25
49
-        '4087072509293123892361',                                   // 26
50
-        '70251601603943959887872',                                  // 27
51
-        '1252259641403629865468285',                                // 28
52
-        '23119184187809597841473536',                               // 29
53
-        '441543893249023104553682821',                              // 30
54
-        '8713962757125169296170811392',                             // 31
55
-        '177519391579539289436664789665',                           // 32
56
-        '3729407703720529571097509625856',                          // 33
57
-        '80723299235887898062168247453281',                         // 34
58
-        '1798651693450888780071750349094912',                       // 35
59
-        '41222060339517702122347079671259045',                      // 36
60
-        '970982810785059112379399707952152576',                     // 37
61
-        '23489580527043108252017828576198947741',                   // 38
62
-        '583203324917310043943191641625494290432',                  // 39
63
-        '14851150718114980017877156781405826684425',                // 40
64
-        '387635983772083031828014624002175135645696',               // 41
65
-        '10364622733519612119397957304745185976310201',             // 42
66
-        '283727921907431909304183316295787837183229952',            // 43
67
-        '7947579422597592703608040510088070619519273805',           // 44
68
-        '227681379129930886488600284336316164603920777216',         // 45
69
-        '6667537516685544977435028474773748197524107684661',        // 46
70
-        '199500252157859031027160499643195658166340757225472',      // 47
71
-        '6096278645568542158691685742876843153976539044435185',     // 48
72
-        '190169564657928428175235445073924928592047775873499136',   // 49
73
-        '6053285248188621896314383785111649088103498225146815121',  // 50
23
+        '1', // 0
24
+        '1', // 1
25
+        '1', // 2
26
+        '2', // 3
27
+        '5', // 4
28
+        '16', // 5
29
+        '61', // 6
30
+        '272', // 7
31
+        '1385', // 8
32
+        '7936', // 9
33
+        '50521', // 10
34
+        '353792', // 11
35
+        '2702765', // 12
36
+        '22368256', // 13
37
+        '199360981', // 14
38
+        '1903757312', // 15
39
+        '19391512145', // 16
40
+        '209865342976', // 17
41
+        '2404879675441', // 18
42
+        '29088885112832', // 19
43
+        '370371188237525', // 20
44
+        '4951498053124096', // 21
45
+        '69348874393137901', // 22
46
+        '1015423886506852352', // 23
47
+        '15514534163557086905', // 24
48
+        '246921480190207983616', // 25
49
+        '4087072509293123892361', // 26
50
+        '70251601603943959887872', // 27
51
+        '1252259641403629865468285', // 28
52
+        '23119184187809597841473536', // 29
53
+        '441543893249023104553682821', // 30
54
+        '8713962757125169296170811392', // 31
55
+        '177519391579539289436664789665', // 32
56
+        '3729407703720529571097509625856', // 33
57
+        '80723299235887898062168247453281', // 34
58
+        '1798651693450888780071750349094912', // 35
59
+        '41222060339517702122347079671259045', // 36
60
+        '970982810785059112379399707952152576', // 37
61
+        '23489580527043108252017828576198947741', // 38
62
+        '583203324917310043943191641625494290432', // 39
63
+        '14851150718114980017877156781405826684425', // 40
64
+        '387635983772083031828014624002175135645696', // 41
65
+        '10364622733519612119397957304745185976310201', // 42
66
+        '283727921907431909304183316295787837183229952', // 43
67
+        '7947579422597592703608040510088070619519273805', // 44
68
+        '227681379129930886488600284336316164603920777216', // 45
69
+        '6667537516685544977435028474773748197524107684661', // 46
70
+        '199500252157859031027160499643195658166340757225472', // 47
71
+        '6096278645568542158691685742876843153976539044435185', // 48
72
+        '190169564657928428175235445073924928592047775873499136', // 49
73
+        '6053285248188621896314383785111649088103498225146815121', // 50
74 74
     ];
75 75
 
76 76
     /**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
         if ($asCollection) {
89 89
             $sequence = new NumberCollection();
90 90
 
91
-            for ($i = 0;$i < $collectionSize;$i++) {
92
-                $sequence->push(self::nthOddNumber($n + $i));
91
+            for ($i = 0; $i < $collectionSize; $i++) {
92
+                $sequence->push(self::nthOddNumber($n+$i));
93 93
             }
94 94
 
95 95
             return $sequence;
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
         if ($asCollection) {
122 122
             $sequence = new NumberCollection();
123 123
 
124
-            for ($i = 0;$i < $collectionSize;$i++) {
125
-                $sequence->push(self::nthEvenNumber($n + $i));
124
+            for ($i = 0; $i < $collectionSize; $i++) {
125
+                $sequence->push(self::nthEvenNumber($n+$i));
126 126
             }
127 127
 
128 128
             return $sequence;
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
         if ($asCollection) {
154 154
             $sequence = new NumberCollection();
155 155
 
156
-            for ($i = 0;$i < $collectionSize;$i++) {
157
-                $sequence->push(self::nthPowerNegativeOne($n + $i));
156
+            for ($i = 0; $i < $collectionSize; $i++) {
157
+                $sequence->push(self::nthPowerNegativeOne($n+$i));
158 158
             }
159 159
 
160 160
             return $sequence;
161 161
         }
162 162
 
163
-        return ($n % 2 ? new ImmutableDecimal(-1) : new ImmutableDecimal(1));
163
+        return ($n%2 ? new ImmutableDecimal(-1) : new ImmutableDecimal(1));
164 164
 
165 165
     }
166 166
 
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
         if ($asCollection) {
181 181
             $sequence = new NumberCollection();
182 182
 
183
-            for ($i = 0;$i < $collectionSize;$i++) {
184
-                $sequence->push(self::nthEulerZigzag($n + $i));
183
+            for ($i = 0; $i < $collectionSize; $i++) {
184
+                $sequence->push(self::nthEulerZigzag($n+$i));
185 185
             }
186 186
 
187 187
             return $sequence;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
         $scale = $scale ?? 5;
218 218
 
219
-        $internalScale = (int)ceil($scale*(log10($scale)+1));
219
+        $internalScale = (int) ceil($scale*(log10($scale)+1));
220 220
 
221 221
         $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n, $internalScale)->setMode(CalcMode::Precision);
222 222
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
         $currentPrime = Numbers::make(Numbers::IMMUTABLE, 3);
319 319
 
320
-        for ($i = 1;$i < $n;$i++) {
320
+        for ($i = 1; $i < $n; $i++) {
321 321
             while (!$currentPrime->isPrime()) {
322 322
                 $currentPrime = $currentPrime->add(2);
323 323
             }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             $sequence = new NumberCollection();
362 362
             $sequence->push($fastFib[0]);
363 363
             $sequence->push($fastFib[1]);
364
-            for ($i = 0;$i < ($collectionSize-2);$i++) {
364
+            for ($i = 0; $i < ($collectionSize-2); $i++) {
365 365
                 $sequence->push($sequence->get($i)->add($sequence[$i+1]));
366 366
             }
367 367
 
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/BaseConversionProvider.php 1 patch
Spacing   +6 added lines, -10 removed lines patch added patch discarded remove patch
@@ -75,16 +75,13 @@  discard block
 block discarded – undo
75 75
         if ($inputInt->isGreaterThan(0)) {
76 76
             for ($pos = 0; $runningTotal->isLessThan($inputInt); $pos++) {
77 77
                 $basePow = $pos ?
78
-                    $baseNum->pow($pos) :
79
-                    $baseNum->pow($pos+1);
78
+                    $baseNum->pow($pos) : $baseNum->pow($pos+1);
80 79
                 $intPart = $pos ? $intPart : '';
81 80
                 $mod = $pos ?
82
-                    (int)gmp_strval(gmp_div_q($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber())) :
83
-                    (int)gmp_strval(gmp_div_r($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber()));
84
-                $intPart = self::$chars[$mod] . $intPart;
81
+                    (int) gmp_strval(gmp_div_q($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber())) : (int) gmp_strval(gmp_div_r($inputInt->getAsBaseTenRealNumber(), $basePow->getAsBaseTenRealNumber()));
82
+                $intPart = self::$chars[$mod].$intPart;
85 83
                 $runningTotal = $pos ?
86
-                    $runningTotal->add($basePow->multiply($mod)) :
87
-                    $runningTotal->add($mod);
84
+                    $runningTotal->add($basePow->multiply($mod)) : $runningTotal->add($mod);
88 85
             }
89 86
         }
90 87
 
@@ -94,9 +91,8 @@  discard block
 block discarded – undo
94 91
                 $basePow = $baseNum->pow($pos);
95 92
                 $decPart = $pos ? $decPart : '';
96 93
                 $mod = $pos ?
97
-                    (int)gmp_strval(gmp_div_q($inputDec->getAsBaseTenRealNumber(), $baseNum->pow($pos)->getAsBaseTenRealNumber())) :
98
-                    $inputDec->modulo($baseNum->pow($pos))->asInt();
99
-                $decPart = self::$chars[$mod] . $decPart;
94
+                    (int) gmp_strval(gmp_div_q($inputDec->getAsBaseTenRealNumber(), $baseNum->pow($pos)->getAsBaseTenRealNumber())) : $inputDec->modulo($baseNum->pow($pos))->asInt();
95
+                $decPart = self::$chars[$mod].$decPart;
100 96
                 $runningTotal = $runningTotal->add($basePow->multiply($mod));
101 97
             }
102 98
         }
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/RandomProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
      * @throws IncompatibleObjectState
31 31
      */
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
         RandomMode $mode = RandomMode::Entropy
36 36
     ): ImmutableDecimal
37 37
     {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     throw new OptionalExit(
108 108
                         'System error from random_bytes().',
109 109
                         'Ensure your system is configured correctly.',
110
-                        '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
+                        '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 111
                     );
112 112
                 }
113 113
             } elseif ($mode == RandomMode::Speed) {
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
                      */
148 148
                     $entropyBytes = random_bytes($bytesNeeded->asInt());
149 149
                     $baseTwoBytes = '';
150
-                    for($i = 0; $i < strlen($entropyBytes); $i++){
151
-                        $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) );
150
+                    for ($i = 0; $i < strlen($entropyBytes); $i++) {
151
+                        $baseTwoBytes .= decbin(ord($entropyBytes[$i]));
152 152
                     }
153 153
                 } catch (Exception $e) {
154 154
                     throw new OptionalExit(
155 155
                         'System error from random_bytes().',
156 156
                         'Ensure your system is configured correctly.',
157
-                        '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()
157
+                        '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 158
                     );
159 159
                 }
160 160
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
      * @throws IncompatibleObjectState
244 244
      */
245 245
     public static function randomReal(
246
-        int|string|DecimalInterface $min,
247
-        int|string|DecimalInterface $max,
246
+        int | string | DecimalInterface $min,
247
+        int | string | DecimalInterface $max,
248 248
         int $scale,
249 249
         RandomMode $mode = RandomMode::Entropy
250 250
     ): ImmutableDecimal
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                  * We cannot take advantage of a more efficient check for the top end of the range, so the
370 370
                  * less than check is all we need.
371 371
                  */
372
-                $maxDecimal = str_pad('1', $scale + 1, '0');
372
+                $maxDecimal = str_pad('1', $scale+1, '0');
373 373
             } else {
374 374
                 /**
375 375
                  * 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/Provider/RoundingProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $roundedPartString = $currentPart ? $decimalPart : $wholePart;
71 71
         $otherPart = $currentPart ? str_split($wholePart) : str_split($decimalPart);
72 72
         $baseLength = $currentPart ? strlen($decimalPart)-1 : strlen($wholePart);
73
-        $pos = $currentPart ? $places : $baseLength + $places;
73
+        $pos = $currentPart ? $places : $baseLength+$places;
74 74
         $carry = 0;
75 75
 
76 76
         if ($currentPart) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 break;
85 85
             }
86 86
 
87
-            $digit = (int)$roundedPart[$pos] + $carry;
87
+            $digit = (int) $roundedPart[$pos]+$carry;
88 88
 
89 89
             if ($carry == 0 && $digit == 5) {
90 90
                 static::$remainder = substr($roundedPartString, $pos+1);
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 
95 95
             if ($pos == 0) {
96 96
                 if ($currentPart) {
97
-                    $nextDigit = (int)$otherPart[count($otherPart)-1];
97
+                    $nextDigit = (int) $otherPart[count($otherPart)-1];
98 98
                 } else {
99 99
                     $nextDigit = 0;
100 100
                 }
101 101
             } else {
102
-                $nextDigit = (int)$roundedPart[$pos-1];
102
+                $nextDigit = (int) $roundedPart[$pos-1];
103 103
             }
104 104
 
105 105
             if ($carry == 0) {
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $remainder = self::remainderCheck();
231 231
 
232 232
         if ($early == 0) {
233
-            return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1;
233
+            return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1;
234 234
         } else {
235 235
             return $early == 1 ? 1 : 0;
236 236
         }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         $remainder = self::remainderCheck();
243 243
 
244 244
         if ($early == 0) {
245
-            return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1;
245
+            return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1;
246 246
         } else {
247 247
             return $early == 1 ? 1 : 0;
248 248
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
         if ($early == 0 && !$remainder) {
294 294
             $val = self::$alt;
295
-            self::$alt = (int)!$val;
295
+            self::$alt = (int) !$val;
296 296
 
297 297
             return $val;
298 298
         } else {
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
             $rangeMax = 9;
311 311
         } else {
312 312
             $remainder = substr($remainder, 0, 3);
313
-            $target = (int)($digit.$remainder);
313
+            $target = (int) ($digit.$remainder);
314 314
             $rangeMin = 0;
315
-            $rangeMax = (int)str_repeat('9', strlen($remainder) + 1);
315
+            $rangeMax = (int) str_repeat('9', strlen($remainder)+1);
316 316
         }
317 317
 
318 318
         $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomMode::Speed)->asInt();
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/ConstantProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
             return self::$pi->truncateToScale($digits)->getValue(NumberBase::Ten);
37 37
         }
38 38
 
39
-        $internalScale = $digits + 10;
39
+        $internalScale = $digits+10;
40 40
 
41 41
         $C = Numbers::make(Numbers::IMMUTABLE, '10005', $internalScale)->setMode(CalcMode::Precision)->sqrt($internalScale)->multiply(426880);
42 42
         $M = Numbers::make(Numbers::IMMUTABLE, '1', $internalScale)->setMode(CalcMode::Precision);
43 43
         $L = Numbers::make(Numbers::IMMUTABLE, '13591409', $internalScale)->setMode(CalcMode::Precision);
44 44
         $K = Numbers::make(Numbers::IMMUTABLE, '6', $internalScale)->setMode(CalcMode::Precision);
45 45
         $X = Numbers::make(Numbers::IMMUTABLE, '1')->setMode(CalcMode::Precision);
46
-        $sum = Numbers::make(Numbers::MUTABLE,'0', $internalScale + 2)->setMode(CalcMode::Precision);
46
+        $sum = Numbers::make(Numbers::MUTABLE, '0', $internalScale+2)->setMode(CalcMode::Precision);
47 47
         $termNum = 0;
48 48
         $one = Numbers::makeOne($internalScale)->setMode(CalcMode::Precision);
49 49
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             return self::$e->truncateToScale($digits)->getValue(NumberBase::Ten);
96 96
         }
97 97
 
98
-        $internalScale = $digits + 3;
98
+        $internalScale = $digits+3;
99 99
 
100 100
         $one = Numbers::makeOne($internalScale+5)->setMode(CalcMode::Precision);
101 101
         $denominator = Numbers::make(Numbers::MUTABLE, '1', $internalScale)->setMode(CalcMode::Precision);
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/SeriesProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@
 block discarded – undo
176 176
         $prevDenominator = new ImmutableDecimal(0, $scale);
177 177
         $loop = 0;
178 178
 
179
-        for ($i = $terms;$i > 0;$i--) {
179
+        for ($i = $terms; $i > 0; $i--) {
180 180
             $loop++;
181 181
             if ($sumMode == self::SUM_MODE_ADD) {
182 182
                 $prevDenominator = $bPart($i)->add($prevDenominator);
Please login to merge, or discard this patch.
src/Samsara/Fermat/Numbers.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
236 236
             }
237 237
 
238 238
             if ($scale > 100) {
239
-                $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale), $scale + 2);
239
+                $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale), $scale+2);
240 240
                 /** @var ImmutableDecimal */
241 241
                 return $pi->multiply(2)->truncateToScale($scale);
242 242
             }
Please login to merge, or discard this patch.