Test Failed
Pull Request — master (#141)
by Jordan
06:39
created
src/Samsara/Fermat/Stats/Types/Distribution.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
         return $sample;
26 26
     }
27 27
 
28
-     abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal;
28
+        abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableDecimal;
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Samsara/Fermat/Stats/Values/Distribution/Exponential.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             );
62 62
         }
63 63
 
64
-        $internalScale = $scale + 2;
64
+        $internalScale = $scale+2;
65 65
 
66 66
         /** @var ImmutableDecimal $e */
67 67
         $e = Numbers::makeE($internalScale);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             );
99 99
         }
100 100
 
101
-        $internalScale = $scale + 2;
101
+        $internalScale = $scale+2;
102 102
 
103 103
         /** @var ImmutableDecimal $e */
104 104
         $e = Numbers::makeE($internalScale);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             );
139 139
         }
140 140
 
141
-        $internalScale = $scale + 2;
141
+        $internalScale = $scale+2;
142 142
 
143 143
         /** @var ImmutableDecimal $rangePdf */
144 144
         $rangePdf =
Please login to merge, or discard this patch.
src/Samsara/Fermat/Stats/Values/Distribution/Normal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
         $e = Numbers::makeE($scale);
81 81
         $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
82 82
 
83
-        $internalScale = (new NumberCollection([$scale, $x]))->selectScale() + 2;
83
+        $internalScale = (new NumberCollection([$scale, $x]))->selectScale()+2;
84 84
 
85 85
         // $left = 1 / ( sqrt(2pi * SD^2) )
86 86
         $left =
Please login to merge, or discard this patch.
src/Samsara/Fermat/Stats/Values/Distribution/Poisson.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @throws IntegrityConstraint
64 64
      * @throws IncompatibleObjectState
65 65
      */
66
-    public function cdf(int|float|DecimalInterface $x, int $scale = 10): ImmutableDecimal
66
+    public function cdf(int | float | DecimalInterface $x, int $scale = 10): ImmutableDecimal
67 67
     {
68 68
 
69 69
         $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             );
77 77
         }
78 78
 
79
-        $internalScale = $scale + 2;
79
+        $internalScale = $scale+2;
80 80
 
81 81
         $cumulative = Numbers::makeZero();
82 82
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @throws IntegrityConstraint
102 102
      * @throws IncompatibleObjectState
103 103
      */
104
-    public function pmf(float|int|DecimalInterface $x, int $scale = 10): ImmutableDecimal
104
+    public function pmf(float | int | DecimalInterface $x, int $scale = 10): ImmutableDecimal
105 105
     {
106 106
         $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
107 107
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             );
114 114
         }
115 115
 
116
-        $internalScale = $scale + 2;
116
+        $internalScale = $scale+2;
117 117
 
118 118
         $e = Numbers::makeE($internalScale);
119 119
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
         while (true) {
260 260
             /** @var ImmutableDecimal $u */
261
-            $u = PolyfillProvider::randomInt(0, PHP_INT_MAX) / PHP_INT_MAX;
261
+            $u = PolyfillProvider::randomInt(0, PHP_INT_MAX)/PHP_INT_MAX;
262 262
             /** @var ImmutableDecimal $x */
263 263
             $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta));
264 264
             /** @var ImmutableDecimal $n */
Please login to merge, or discard this patch.
src/Samsara/Fermat/Stats/Provider/StatsProvider.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
                 ->multiply($e->pow($eExponent))
54 54
                 ->multiply(SeriesProvider::maclaurinSeries(
55 55
                     $x,
56
-                    function ($n) {
56
+                    function($n) {
57 57
                         return Numbers::makeOne();
58 58
                     },
59
-                    function ($n) {
59
+                    function($n) {
60 60
                         return SequenceProvider::nthOddNumber($n);
61 61
                     },
62
-                    function ($n) {
62
+                    function($n) {
63 63
                         return SequenceProvider::nthOddNumber($n)->doubleFactorial();
64 64
                     },
65 65
                     0,
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $x = Numbers::makeOrDont(Numbers::IMMUTABLE, $x);
103 103
 
104 104
         $scale = $x->getScale();
105
-        $internalScale = $scale + 2;
105
+        $internalScale = $scale+2;
106 106
 
107 107
         $answer = Numbers::makeOne($internalScale);
108 108
         $pi = Numbers::makePi($internalScale);
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
         $answer = $answer->multiply(
113 113
             SeriesProvider::maclaurinSeries(
114 114
                 $x,
115
-                function ($n) {
115
+                function($n) {
116 116
                     $negOne = Numbers::make(Numbers::IMMUTABLE, -1);
117 117
 
118 118
                     return $negOne->pow($n);
119 119
                 },
120
-                function ($n) {
120
+                function($n) {
121 121
                     return SequenceProvider::nthOddNumber($n);
122 122
                 },
123
-                function ($n) {
123
+                function($n) {
124 124
                     $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n);
125 125
 
126 126
                     return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n->asInt()));
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $p = Numbers::makeOrDont(Numbers::IMMUTABLE, $p);
150 150
 
151 151
         $scale = $scale ?? $p->getScale();
152
-        $internalScale = $scale + $p->numberOfDecimalDigits();
152
+        $internalScale = $scale+$p->numberOfDecimalDigits();
153 153
 
154 154
         $two = Numbers::make(Numbers::IMMUTABLE, 2, $internalScale);
155 155
         $invErfArg = $two->multiply($p)->subtract(1);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             static::$inverseErrorCoefs->push(new ImmutableFraction(Numbers::makeOne(), Numbers::makeOne()));
201 201
         }
202 202
 
203
-        $terms =& static::$inverseErrorCoefs;
203
+        $terms = & static::$inverseErrorCoefs;
204 204
 
205 205
         if ($terms->offsetExists($termIndex)) {
206 206
             return $terms->get($termIndex);
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 
211 211
         for ($k = $nextTerm;$k <= $termIndex;$k++) {
212 212
             $termValue = new ImmutableFraction(new ImmutableDecimal('0'), new ImmutableDecimal('1'));
213
-            for ($m = 0;$m <= ($k - 1);$m++) {
213
+            for ($m = 0;$m <= ($k-1);$m++) {
214 214
                 $part1 = $terms->get($m);
215
-                $part2 = $terms->get($k - 1 - $m);
215
+                $part2 = $terms->get($k-1-$m);
216 216
                 $part3 = $part1->multiply($part2);
217
-                $part4 = ($m + 1)*($m*2 + 1);
217
+                $part4 = ($m+1)*($m*2+1);
218 218
                 $part5 = $part3->divide($part4);
219 219
                 $termValue = $termValue->add($part5);
220 220
             }
@@ -243,23 +243,23 @@  discard block
 block discarded – undo
243 243
         $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $z);
244 244
 
245 245
         $scale = $scale ?? $z->getScale();
246
-        $internalScale = $scale + $z->numberOfDecimalDigits();
246
+        $internalScale = $scale+$z->numberOfDecimalDigits();
247 247
 
248 248
         $pi = Numbers::makePi($internalScale);
249 249
 
250 250
         $answer = SeriesProvider::maclaurinSeries(
251 251
             $z,
252
-            static function ($n) use ($pi) {
252
+            static function($n) use ($pi) {
253 253
                 if ($n > 0) {
254 254
                     return $pi->pow($n)->multiply(StatsProvider::inverseErrorCoefficients($n));
255 255
                 }
256 256
 
257 257
                 return Numbers::makeOne();
258 258
             },
259
-            static function ($n) {
259
+            static function($n) {
260 260
                 return SequenceProvider::nthOddNumber($n);
261 261
             },
262
-            static function ($n) {
262
+            static function($n) {
263 263
                 if ($n > 0) {
264 264
                     $extra = Numbers::make(Numbers::IMMUTABLE, 2)->pow(SequenceProvider::nthEvenNumber($n));
265 265
                 } else {
Please login to merge, or discard this patch.
src/Samsara/Fermat/Core/Types/Base/Interfaces/Numbers/DecimalInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      *
25 25
      * @return DecimalInterface
26 26
      */
27
-    public function continuousModulo(NumberInterface|string|int|float $mod): DecimalInterface;
27
+    public function continuousModulo(NumberInterface | string | int | float $mod): DecimalInterface;
28 28
 
29 29
     /**
30 30
      * @param $num
Please login to merge, or discard this patch.
src/Samsara/Fermat/Core/Types/Traits/Decimal/LogScaleTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
             $e = Numbers::makeE($scale+$addScale);
49 49
             $value = $e->pow($this);
50 50
         } else {
51
-            $intScale = ($this->numberOfIntDigits()) ? ($scale + 2) * $this->numberOfIntDigits() : ($scale + 2);
52
-            $intScale = ($this->numberOfLeadingZeros()) ? $intScale * $this->numberOfLeadingZeros() : $intScale;
51
+            $intScale = ($this->numberOfIntDigits()) ? ($scale+2)*$this->numberOfIntDigits() : ($scale+2);
52
+            $intScale = ($this->numberOfLeadingZeros()) ? $intScale*$this->numberOfLeadingZeros() : $intScale;
53 53
             $x = $this instanceof ImmutableDecimal ? $this : new ImmutableDecimal($this->getValue(NumberBase::Ten), $intScale);
54 54
             $x2 = $x->pow(2);
55 55
             $terms = $scale;
56 56
             $six = new ImmutableDecimal(6, $intScale);
57 57
 
58
-            $aPart = new class($x2, $x) implements ContinuedFractionTermInterface{
58
+            $aPart = new class($x2, $x) implements ContinuedFractionTermInterface {
59 59
                 private ImmutableDecimal $x2;
60 60
                 private ImmutableDecimal $x;
61 61
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 }
84 84
             };
85 85
 
86
-            $bPart = new class($x, $six, $intScale) implements ContinuedFractionTermInterface{
86
+            $bPart = new class($x, $six, $intScale) implements ContinuedFractionTermInterface {
87 87
                 private ImmutableDecimal $x;
88 88
                 private ImmutableDecimal $six;
89 89
                 private int $intScale;
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     protected function lnScale(int $scale = null): string
134 134
     {
135 135
         $internalScale = $scale ?? $this->getScale();
136
-        $internalScale += 3 + $this->numberOfLeadingZeros();
136
+        $internalScale += 3+$this->numberOfLeadingZeros();
137 137
 
138 138
         if (extension_loaded('decimal')) {
139 139
             $decimalScale = max($internalScale*2, $this->numberOfTotalDigits()*2);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $answer = $adjustedNum;
194 194
 
195 195
         if ($exp2) {
196
-            $answer = $answer->add(Numbers::makeNaturalLog2($internalScale + abs($exp2))->multiply($exp2));
196
+            $answer = $answer->add(Numbers::makeNaturalLog2($internalScale+abs($exp2))->multiply($exp2));
197 197
         }
198 198
 
199 199
         if ($exp1p1) {
Please login to merge, or discard this patch.
src/Samsara/Fermat/Core/Types/Traits/Decimal/FormatterTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             $baseValue = $this->trimmedScientificString($scale, $baseValue);
124 124
 
125 125
             if ($this->isNegative()) {
126
-                $baseValue = '-' . $baseValue;
126
+                $baseValue = '-'.$baseValue;
127 127
             }
128 128
 
129 129
             if ($this->isImaginary()) {
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
      */
142 142
     private function trimmedScientificString(int $scale, string $baseValue): string
143 143
     {
144
-        if ($this->numberOfIntDigits() > $scale + 1) {
145
-            $baseValue = substr($this->getWholePart(), 0, $scale + 1);
144
+        if ($this->numberOfIntDigits() > $scale+1) {
145
+            $baseValue = substr($this->getWholePart(), 0, $scale+1);
146 146
             $baseValue = str_pad($baseValue, $this->numberOfIntDigits(), '0');
147
-        } elseif ($this->getWholePart() == '0' && $this->numberOfSigDecimalDigits() > $scale + 1) {
147
+        } elseif ($this->getWholePart() == '0' && $this->numberOfSigDecimalDigits() > $scale+1) {
148 148
             $baseValue = trim($this->getDecimalPart(), '0');
149
-            $baseValue = substr($baseValue, 0, $scale + 1);
150
-            $baseValue = str_pad($baseValue, $this->numberOfLeadingZeros() + strlen($baseValue), '0', STR_PAD_LEFT);
151
-            $baseValue = '0.' . $baseValue;
152
-        } elseif ($this->numberOfTotalDigits() > $scale + 1) {
149
+            $baseValue = substr($baseValue, 0, $scale+1);
150
+            $baseValue = str_pad($baseValue, $this->numberOfLeadingZeros()+strlen($baseValue), '0', STR_PAD_LEFT);
151
+            $baseValue = '0.'.$baseValue;
152
+        } elseif ($this->numberOfTotalDigits() > $scale+1) {
153 153
             $baseValue = $this->getWholePart()
154 154
                 . '.'
155
-                . substr($this->getDecimalPart(), 0, ($scale + 1) - $this->numberOfIntDigits());
155
+                . substr($this->getDecimalPart(), 0, ($scale+1)-$this->numberOfIntDigits());
156 156
         }
157 157
 
158 158
         return $baseValue;
Please login to merge, or discard this patch.
src/Samsara/Fermat/Core/Types/Traits/Decimal/ScaleTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         $total = strlen($fractional);
148 148
         $fractional = ltrim($fractional, '0');
149 149
 
150
-        return ($total - strlen($fractional));
150
+        return ($total-strlen($fractional));
151 151
     }
152 152
 
153 153
     /**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function numberOfTotalDigits(): int
159 159
     {
160
-        return $this->numberOfDecimalDigits() + $this->numberOfIntDigits();
160
+        return $this->numberOfDecimalDigits()+$this->numberOfIntDigits();
161 161
     }
162 162
 
163 163
     /**
Please login to merge, or discard this patch.