@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Samsara\Fermat; |
| 4 | 4 | |
| 5 | -use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
| 6 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
| 7 | -use Samsara\Fermat\Types\Base\FractionInterface; |
|
| 8 | -use Samsara\Fermat\Values\Currency; |
|
| 9 | -use Samsara\Fermat\Values\ImmutableFraction; |
|
| 10 | -use Samsara\Fermat\Values\ImmutableNumber; |
|
| 11 | -use Samsara\Fermat\Values\MutableFraction; |
|
| 12 | -use Samsara\Fermat\Values\MutableNumber; |
|
| 5 | +use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
| 6 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
| 7 | +use Samsara\Fermat\Types\Base\FractionInterface; |
|
| 8 | +use Samsara\Fermat\Values\Currency; |
|
| 9 | +use Samsara\Fermat\Values\ImmutableFraction; |
|
| 10 | +use Samsara\Fermat\Values\ImmutableNumber; |
|
| 11 | +use Samsara\Fermat\Values\MutableFraction; |
|
| 12 | +use Samsara\Fermat\Values\MutableNumber; |
|
| 13 | 13 | use Samsara\Fermat\Types\Base\NumberInterface; |
| 14 | 14 | |
| 15 | 15 | class Numbers |
@@ -24,6 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected $denominator; |
| 26 | 26 | |
| 27 | + /** |
|
| 28 | + * @param ImmutableNumber $numerator |
|
| 29 | + * @param ImmutableNumber $denominator |
|
| 30 | + */ |
|
| 27 | 31 | public function __construct($numerator, $denominator, $base = 10) |
| 28 | 32 | { |
| 29 | 33 | |
@@ -325,6 +329,9 @@ discard block |
||
| 325 | 329 | return $lcm; |
| 326 | 330 | } |
| 327 | 331 | |
| 332 | + /** |
|
| 333 | + * @param integer $base |
|
| 334 | + */ |
|
| 328 | 335 | public function convertToBase($base) |
| 329 | 336 | { |
| 330 | 337 | $converter = new BaseConverter($this->getBase(), $base); |
@@ -52,6 +52,9 @@ discard block |
||
| 52 | 52 | return $this->precision; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + /** |
|
| 56 | + * @param NumberInterface $num |
|
| 57 | + */ |
|
| 55 | 58 | public function add($num) |
| 56 | 59 | {
|
| 57 | 60 | if (is_object($num) && method_exists($num, 'asDecimal')) {
|
@@ -113,8 +116,8 @@ discard block |
||
| 113 | 116 | * Note about precision: it uses the smaller of the two precisions (significant figures). |
| 114 | 117 | * |
| 115 | 118 | * @param $num |
| 116 | - * @param $precision |
|
| 117 | - * @return mixed |
|
| 119 | + * @param integer $precision |
|
| 120 | + * @return NumberInterface |
|
| 118 | 121 | */ |
| 119 | 122 | public function divide($num, $precision = null) |
| 120 | 123 | {
|
@@ -421,6 +424,9 @@ discard block |
||
| 421 | 424 | |
| 422 | 425 | } |
| 423 | 426 | |
| 427 | + /** |
|
| 428 | + * @param ImmutableNumber $num |
|
| 429 | + */ |
|
| 424 | 430 | public function getGreatestCommonDivisor($num) |
| 425 | 431 | {
|
| 426 | 432 | /** @var ImmutableNumber $num */ |