Skip to content

Commit

Permalink
BigDecimal::dividedBy()'s $scale parameter is optional again
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Aug 6, 2015
1 parent b326cd8 commit 08c6979
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/BigDecimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ public function multipliedBy($that)
* Returns the result of the division of this number by the given one, at the given scale.
*
* @param BigNumber|number|string $that The divisor.
* @param int $scale The desired scale.
* @param int|null $scale The desired scale, or null to use the scale of this number.
* @param int $roundingMode An optional rounding mode.
*
* @return BigDecimal
*
* @throws \InvalidArgumentException If the rounding mode is invalid.
* @throws \InvalidArgumentException If the scale or rounding mode is invalid.
* @throws ArithmeticException If the number is invalid, is zero, or rounding was necessary.
*/
public function dividedBy($that, $scale, $roundingMode = RoundingMode::UNNECESSARY)
public function dividedBy($that, $scale = null, $roundingMode = RoundingMode::UNNECESSARY)
{
$that = BigDecimal::of($that);

Expand Down
13 changes: 7 additions & 6 deletions tests/BigDecimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ public function providerMultipliedBy()
/**
* @dataProvider providerDividedBy
*
* @param string $a The base number.
* @param string $b The number to multiply.
* @param int $scale The desired scale of the result.
* @param int $roundingMode The rounding mode.
* @param string $unscaledValue The expected unscaled value of the result.
* @param int $expectedScale The expected scale of the result.
* @param string $a The base number.
* @param string $b The number to divide.
* @param int|null $scale The desired scale of the result.
* @param int $roundingMode The rounding mode.
* @param string $unscaledValue The expected unscaled value of the result.
* @param int $expectedScale The expected scale of the result.
*/
public function testDividedBy($a, $b, $scale, $roundingMode, $unscaledValue, $expectedScale)
{
Expand All @@ -606,6 +606,7 @@ public function providerDividedBy()
['-32479478384783947298.3343898', '1', 7, RoundingMode::UNNECESSARY, '-324794783847839472983343898', 7],

['1.5', '2', 2, RoundingMode::UNNECESSARY, '75', 2],
['1.5', '3', null, RoundingMode::UNNECESSARY, '5', 1],
['0.123456789', '0.00244140625', 10, RoundingMode::UNNECESSARY, '505679007744', 10],
['1.234', '123.456', 50, RoundingMode::DOWN, '999546397096941420425090720580611715914981855883', 50],
['1', '3', 10, RoundingMode::UP, '3333333334', 10],
Expand Down

0 comments on commit 08c6979

Please sign in to comment.