Completed
Push — dev ( c45123...12c6ba )
by Jordan
02:43
created
src/Samsara/Fermat/Values/ImmutableNumber.php 2 patches
Unused Use Statements   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Values;
4 4
 
5
-use Samsara\Fermat\Numbers;
6
-use Samsara\Fermat\Types\Number;
7
-use Samsara\Fermat\Types\Base\DecimalInterface;
5
+use Samsara\Fermat\Numbers;
6
+use Samsara\Fermat\Types\Number;
7
+use Samsara\Fermat\Types\Base\DecimalInterface;
8 8
 use Samsara\Fermat\Types\Base\NumberInterface;
9 9
 
10 10
 class ImmutableNumber extends Number implements NumberInterface, DecimalInterface
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
 class ImmutableNumber extends Number implements NumberInterface, DecimalInterface
11 11
 {
12 12
 
13
+    /**
14
+     * @param ImmutableNumber $mod
15
+     */
13 16
     public function modulo($mod)
14 17
     {
15 18
         $oldBase = $this->convertForModification();
Please login to merge, or discard this patch.
src/Samsara/Fermat/Values/MutableNumber.php 1 patch
Unused Use Statements   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Values;
4 4
 
5
-use Samsara\Fermat\Types\Number;
6
-use Samsara\Fermat\Types\Base\DecimalInterface;
7
-use Samsara\Fermat\Types\Base\NumberInterface;
5
+use Samsara\Fermat\Types\Number;
6
+use Samsara\Fermat\Types\Base\DecimalInterface;
7
+use Samsara\Fermat\Types\Base\NumberInterface;
8 8
 use Samsara\Fermat\Numbers;
9 9
 
10 10
 class MutableNumber extends Number implements NumberInterface, DecimalInterface
Please login to merge, or discard this patch.
src/Samsara/Fermat/Types/Tuple.php 1 patch
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Types;
4 4
 
5
-use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;
6
-use Samsara\Fermat\Numbers;
5
+use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;
6
+use Samsara\Fermat\Numbers;
7 7
 use Samsara\Fermat\Values\ImmutableNumber;
8 8
 
9 9
 class Tuple
Please login to merge, or discard this patch.
src/Samsara/Fermat/Numbers.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -306,6 +306,7 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     /**
309
+     * @param integer $precision
309 310
      * @return ImmutableNumber
310 311
      */
311 312
     public static function makeOne($precision = null)
@@ -314,6 +315,7 @@  discard block
 block discarded – undo
314 315
     }
315 316
 
316 317
     /**
318
+     * @param integer $precision
317 319
      * @return ImmutableNumber
318 320
      */
319 321
     public static function makeZero($precision = null)
Please login to merge, or discard this patch.
Unused Use Statements   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat;
4 4
 
5
-use Samsara\Exceptions\UsageError\IntegrityConstraint;
6
-use Samsara\Fermat\Types\Base\CoordinateInterface;
7
-use Samsara\Fermat\Types\Base\DecimalInterface;
8
-use Samsara\Fermat\Types\Base\FractionInterface;
9
-use Samsara\Fermat\Types\Fraction;
10
-use Samsara\Fermat\Values\CartesianCoordinate;
11
-use Samsara\Fermat\Values\ImmutableFraction;
12
-use Samsara\Fermat\Values\ImmutableNumber;
13
-use Samsara\Fermat\Values\MutableFraction;
14
-use Samsara\Fermat\Values\MutableNumber;
5
+use Samsara\Exceptions\UsageError\IntegrityConstraint;
6
+use Samsara\Fermat\Types\Base\CoordinateInterface;
7
+use Samsara\Fermat\Types\Base\DecimalInterface;
8
+use Samsara\Fermat\Types\Base\FractionInterface;
9
+use Samsara\Fermat\Types\Fraction;
10
+use Samsara\Fermat\Values\CartesianCoordinate;
11
+use Samsara\Fermat\Values\ImmutableFraction;
12
+use Samsara\Fermat\Values\ImmutableNumber;
13
+use Samsara\Fermat\Values\MutableFraction;
14
+use Samsara\Fermat\Values\MutableNumber;
15 15
 use Samsara\Fermat\Types\Base\NumberInterface;
16 16
 
17 17
 class Numbers
Please login to merge, or discard this patch.
src/Samsara/Fermat/Types/Number.php 3 patches
Doc Comments   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      * Note about precision: it uses the smaller of the two precisions (significant figures).
132 132
      *
133 133
      * @param $num
134
-     * @param $precision
134
+     * @param integer $precision
135 135
      * @return DecimalInterface|NumberInterface
136 136
      */
137 137
     public function divide($num, $precision = null)
@@ -544,6 +544,9 @@  discard block
 block discarded – undo
544 544
 
545 545
     }
546 546
 
547
+    /**
548
+     * @param ImmutableNumber $num
549
+     */
547 550
     public function getGreatestCommonDivisor($num)
548 551
     {
549 552
         /** @var ImmutableNumber $num */
@@ -938,6 +941,10 @@  discard block
 block discarded – undo
938 941
         return strpos($this->value, '.');
939 942
     }
940 943
 
944
+    /**
945
+     * @param integer $pos
946
+     * @param integer $add
947
+     */
941 948
     protected function reduceDecimals(array $decimalArray, $pos, $add)
942 949
     {
943 950
 
@@ -987,9 +994,9 @@  discard block
 block discarded – undo
987 994
     abstract public function modulo($mod);
988 995
 
989 996
     /**
990
-     * @param $mod
997
+     * @param NumberInterface $mod
991 998
      *
992
-     * @return NumberInterface|DecimalInterface
999
+     * @return NumberInterface
993 1000
      */
994 1001
     abstract public function continuousModulo($mod);
995 1002
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public function __construct($value, $precision = 10, $base = 10)
33 33
     {
34 34
         $this->base = $base;
35
-        $this->value = (string)$value;
35
+        $this->value = (string) $value;
36 36
         
37 37
         if (!is_null($precision)) {
38 38
             if ($precision > 100) {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $curVal = $this->getValue();
192 192
         $calcVal = Numbers::make(Numbers::IMMUTABLE, 1);
193 193
 
194
-        for ($i = 1;$i <= $curVal;$i++) {
194
+        for ($i = 1; $i <= $curVal; $i++) {
195 195
             $calcVal = $calcVal->multiply($i);
196 196
         }
197 197
 
@@ -407,15 +407,15 @@  discard block
 block discarded – undo
407 407
 
408 408
         $answer = SeriesProvider::maclaurinSeries(
409 409
             $modulo,
410
-            function ($n) {
410
+            function($n) {
411 411
                 $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100);
412 412
 
413 413
                 return $negOne->pow($n);
414 414
             },
415
-            function ($n) {
415
+            function($n) {
416 416
                 return SequenceProvider::nthOddNumber($n);
417 417
             },
418
-            function ($n) {
418
+            function($n) {
419 419
                 return SequenceProvider::nthOddNumber($n)->factorial();
420 420
             },
421 421
             0,
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 
450 450
         $answer = SeriesProvider::maclaurinSeries(
451 451
             $modulo,
452
-            function ($n) {
452
+            function($n) {
453 453
                 return SequenceProvider::nthPowerNegativeOne($n);
454 454
             },
455
-            function ($n) {
455
+            function($n) {
456 456
                 return SequenceProvider::nthEvenNumber($n);
457 457
             },
458
-            function ($n) {
458
+            function($n) {
459 459
                 return SequenceProvider::nthEvenNumber($n)->factorial();
460 460
             },
461 461
             0,
@@ -540,20 +540,20 @@  discard block
 block discarded – undo
540 540
         } else {
541 541
             $answer = SeriesProvider::maclaurinSeries(
542 542
                 $modulo,
543
-                function ($n) {
543
+                function($n) {
544 544
                     $nthOddNumber = SequenceProvider::nthOddNumber($n);
545 545
 
546 546
                     return SequenceProvider::nthEulerZigzag($nthOddNumber);
547 547
                 },
548
-                function ($n) {
548
+                function($n) {
549 549
 
550 550
                     return SequenceProvider::nthOddNumber($n);
551 551
                 },
552
-                function ($n) {
552
+                function($n) {
553 553
                     return SequenceProvider::nthOddNumber($n)->factorial();
554 554
                 },
555 555
                 0,
556
-                $precision + 1
556
+                $precision+1
557 557
             );
558 558
         }
559 559
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
         if ($mod2Pi->isEqual(0)) {
594 594
             return $this->setValue(static::INFINITY);
595
-        } elseif($modPi->isEqual(0)) {
595
+        } elseif ($modPi->isEqual(0)) {
596 596
             return $this->setValue(static::NEG_INFINITY);
597 597
         }
598 598
 
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
                 $rounded = $whole.'.';
1192 1192
 
1193
-                for ($i = 0;$i < $decimals;$i++) {
1193
+                for ($i = 0; $i < $decimals; $i++) {
1194 1194
                     $rounded .= $fractionalArr[$i];
1195 1195
                 }
1196 1196
 
Please login to merge, or discard this patch.
Unused Use Statements   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2,17 +2,17 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Types;
4 4
 
5
-use Ds\Hashable;
6
-use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;
7
-use Samsara\Exceptions\UsageError\IntegrityConstraint;
8
-use Samsara\Fermat\Numbers;
9
-use Samsara\Fermat\Provider\ArithmeticProvider;
10
-use Riimu\Kit\BaseConversion\BaseConverter;
11
-use Samsara\Fermat\Provider\SequenceProvider;
12
-use Samsara\Fermat\Provider\SeriesProvider;
13
-use Samsara\Fermat\Provider\StatsProvider;
14
-use Samsara\Fermat\Types\Base\DecimalInterface;
15
-use Samsara\Fermat\Types\Base\NumberInterface;
5
+use Ds\Hashable;
6
+use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState;
7
+use Samsara\Exceptions\UsageError\IntegrityConstraint;
8
+use Samsara\Fermat\Numbers;
9
+use Samsara\Fermat\Provider\ArithmeticProvider;
10
+use Riimu\Kit\BaseConversion\BaseConverter;
11
+use Samsara\Fermat\Provider\SequenceProvider;
12
+use Samsara\Fermat\Provider\SeriesProvider;
13
+use Samsara\Fermat\Provider\StatsProvider;
14
+use Samsara\Fermat\Types\Base\DecimalInterface;
15
+use Samsara\Fermat\Types\Base\NumberInterface;
16 16
 use Samsara\Fermat\Values\ImmutableNumber;
17 17
 
18 18
 abstract class Number implements Hashable
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/Distribution/Exponential.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@
 block discarded – undo
178 178
     }
179 179
 
180 180
     /**
181
-     * @param int|float|DecimalInterface $min
181
+     * @param integer $min
182 182
      * @param int|float|DecimalInterface $max
183 183
      * @param int $maxIterations
184 184
      *
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
         $randFactory = new Factory();
169 169
         $generator = $randFactory->getMediumStrengthGenerator();
170 170
         $one = Numbers::makeOne();
171
-        $u = $generator->generateInt() / PHP_INT_MAX;
171
+        $u = $generator->generateInt()/PHP_INT_MAX;
172 172
 
173 173
         /** @var ImmutableNumber $random */
174 174
         $random = $one->subtract($u)->ln()->divide($this->lambda->multiply(-1));
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/Distribution/Normal.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
      * WARNING: This function is of very limited use with Poisson distributions, and may represent a SIGNIFICANT
164 164
      * performance hit for certain values of $min, $max, $lambda, and $maxIterations
165 165
      *
166
-     * @param int|float|NumberInterface $min
166
+     * @param integer $min
167 167
      * @param int|float|NumberInterface $max
168 168
      * @param int $maxIterations
169 169
      *
Please login to merge, or discard this patch.
Unused Use Statements   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Provider\Distribution;
4 4
 
5
-use RandomLib\Factory;
6
-use Samsara\Exceptions\UsageError\OptionalExit;
7
-use Samsara\Fermat\Numbers;
8
-use Samsara\Fermat\Provider\StatsProvider;
9
-use Samsara\Fermat\Types\Base\DecimalInterface;
10
-use Samsara\Fermat\Types\Base\NumberInterface;
5
+use RandomLib\Factory;
6
+use Samsara\Exceptions\UsageError\OptionalExit;
7
+use Samsara\Fermat\Numbers;
8
+use Samsara\Fermat\Provider\StatsProvider;
9
+use Samsara\Fermat\Types\Base\DecimalInterface;
10
+use Samsara\Fermat\Types\Base\NumberInterface;
11 11
 use Samsara\Fermat\Values\ImmutableNumber;
12 12
 
13 13
 class Normal
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/Distribution/Poisson.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
      * WARNING: This function is of very limited use with Poisson distributions, and may represent a SIGNIFICANT
164 164
      * performance hit for certain values of $min, $max, $lambda, and $maxIterations
165 165
      *
166
-     * @param int|float|NumberInterface $min
166
+     * @param integer $min
167 167
      * @param int|float|NumberInterface $max
168 168
      * @param int $maxIterations
169 169
      *
Please login to merge, or discard this 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
 
64 64
         $cumulative = Numbers::makeZero();
65 65
 
66
-        for ($i = 0;$x->isGreaterThanOrEqualTo($i);$i++) {
66
+        for ($i = 0; $x->isGreaterThanOrEqualTo($i); $i++) {
67 67
             $cumulative = $cumulative->add($this->pmf($i));
68 68
         }
69 69
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         $cumulative = Numbers::makeZero();
135 135
 
136
-        for (;$larger->isGreaterThanOrEqualTo($smaller);$smaller->add(1)) {
136
+        for (;$larger->isGreaterThanOrEqualTo($smaller); $smaller->add(1)) {
137 137
             $cumulative = $cumulative->add($this->pmf($smaller));
138 138
         }
139 139
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
         while (true) {
220 220
             /** @var ImmutableNumber $u */
221
-            $u = $generator->generateInt() / PHP_INT_MAX;
221
+            $u = $generator->generateInt()/PHP_INT_MAX;
222 222
             /** @var ImmutableNumber $x */
223 223
             $x = $alpha->subtract($one->subtract($u)->divide($u)->ln(20)->divide($beta));
224 224
             /** @var ImmutableNumber $n */
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
             }
230 230
 
231 231
             /** @var ImmutableNumber $v */
232
-            $v = $generator->generateInt() / PHP_INT_MAX;
232
+            $v = $generator->generateInt()/PHP_INT_MAX;
233 233
             /** @var ImmutableNumber $y */
234 234
             $y = $alpha->subtract($beta->multiply($x));
235 235
             /** @var ImmutableNumber $lhs */
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         do {
271 271
             $k = $k->add(1);
272 272
             /** @var ImmutableNumber $u */
273
-            $u = $randFactory->getMediumStrengthGenerator()->generateInt() / PHP_INT_MAX;
273
+            $u = $randFactory->getMediumStrengthGenerator()->generateInt()/PHP_INT_MAX;
274 274
             $p = $p->multiply($u);
275 275
         } while ($p->isGreaterThan($L));
276 276
 
Please login to merge, or discard this patch.
Unused Use Statements   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
2 2
 
3 3
 namespace Samsara\Fermat\Provider\Distribution;
4 4
 
5
-use RandomLib\Factory;
6
-use Samsara\Exceptions\UsageError\IntegrityConstraint;
7
-use Samsara\Exceptions\UsageError\OptionalExit;
8
-use Samsara\Fermat\Numbers;
9
-use Samsara\Fermat\Types\Base\DecimalInterface;
10
-use Samsara\Fermat\Types\Base\NumberInterface;
5
+use RandomLib\Factory;
6
+use Samsara\Exceptions\UsageError\IntegrityConstraint;
7
+use Samsara\Exceptions\UsageError\OptionalExit;
8
+use Samsara\Fermat\Numbers;
9
+use Samsara\Fermat\Types\Base\DecimalInterface;
10
+use Samsara\Fermat\Types\Base\NumberInterface;
11 11
 use Samsara\Fermat\Values\ImmutableNumber;
12 12
 
13 13
 class Poisson
Please login to merge, or discard this patch.
src/Samsara/Fermat/Provider/StatsProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
                 ->multiply($e->pow($eExponent))
33 33
                 ->multiply(SeriesProvider::maclaurinSeries(
34 34
                     $x,
35
-                    function ($n) {
35
+                    function($n) {
36 36
                         return Numbers::makeOne();
37 37
                     },
38
-                    function ($n) {
38
+                    function($n) {
39 39
                         return SequenceProvider::nthOddNumber($n);
40 40
                     },
41
-                    function ($n) {
41
+                    function($n) {
42 42
                         return SequenceProvider::nthOddNumber($n)->doubleFactorial();
43 43
                     }
44 44
                 ))
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
         $answer = $answer->multiply(
69 69
             SeriesProvider::maclaurinSeries(
70 70
                 $x,
71
-                function ($n) {
71
+                function($n) {
72 72
                     $negOne = Numbers::make(Numbers::IMMUTABLE, -1);
73 73
 
74 74
                     return $negOne->pow($n);
75 75
                 },
76
-                function ($n) {
76
+                function($n) {
77 77
                     return SequenceProvider::nthOddNumber($n);
78 78
                 },
79
-                function ($n) {
79
+                function($n) {
80 80
                     $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n);
81 81
 
82 82
                     return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n));
Please login to merge, or discard this patch.