mirror of
https://github.com/danog/math.git
synced 2024-11-30 04:19:31 +01:00
Change Money::dividedBy() parameter order
This commit is contained in:
parent
4f3095cca1
commit
c642d0d0c9
@ -246,15 +246,12 @@ class BigDecimal implements \Serializable
|
|||||||
* Returns the result of the division of this number and the given one.
|
* Returns the result of the division of this number and the given one.
|
||||||
*
|
*
|
||||||
* @param BigDecimal|number|string $that The number to divide.
|
* @param BigDecimal|number|string $that The number to divide.
|
||||||
* @param integer|null $scale The scale, or null to use the scale of this number.
|
* @param int $roundingMode The rounding mode.
|
||||||
* @param integer $roundingMode The rounding mode.
|
* @param int|null $scale The desired scale, or null to use the scale of this number.
|
||||||
*
|
*
|
||||||
* @return BigDecimal
|
* @return BigDecimal
|
||||||
*
|
|
||||||
* @throws ArithmeticException If the divisor is zero or rounding is necessary.
|
|
||||||
* @throws \InvalidArgumentException If the divisor, the scale or the rounding mode is invalid.
|
|
||||||
*/
|
*/
|
||||||
public function dividedBy($that, $scale = null, $roundingMode = RoundingMode::UNNECESSARY)
|
public function dividedBy($that, $roundingMode = RoundingMode::UNNECESSARY, $scale = null)
|
||||||
{
|
{
|
||||||
$that = BigDecimal::of($that);
|
$that = BigDecimal::of($that);
|
||||||
|
|
||||||
@ -357,7 +354,7 @@ class BigDecimal implements \Serializable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->dividedBy(1, $scale, $roundingMode);
|
return $this->dividedBy(1, $roundingMode, $scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -626,7 +623,7 @@ class BigDecimal implements \Serializable
|
|||||||
return BigInteger::of($this->value);
|
return BigInteger::of($this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BigInteger::of($this->dividedBy(1, 0, $roundingMode)->value);
|
return BigInteger::of($this->dividedBy(1, $roundingMode, 0)->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -544,7 +544,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDividedBy($a, $b, $scale, $roundingMode, $unscaledValue, $expectedScale)
|
public function testDividedBy($a, $b, $scale, $roundingMode, $unscaledValue, $expectedScale)
|
||||||
{
|
{
|
||||||
$decimal = BigDecimal::of($a)->dividedBy($b, $scale, $roundingMode);
|
$decimal = BigDecimal::of($a)->dividedBy($b, $roundingMode, $scale);
|
||||||
$this->assertBigDecimalEquals($unscaledValue, $expectedScale, $decimal);
|
$this->assertBigDecimalEquals($unscaledValue, $expectedScale, $decimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDividedByWithRoundingNecessaryThrowsException($a, $b, $scale)
|
public function testDividedByWithRoundingNecessaryThrowsException($a, $b, $scale)
|
||||||
{
|
{
|
||||||
BigDecimal::of($a)->dividedBy($b, $scale);
|
BigDecimal::of($a)->dividedBy($b, RoundingMode::UNNECESSARY, $scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -621,7 +621,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDividedByWithNegativeScaleThrowsException()
|
public function testDividedByWithNegativeScaleThrowsException()
|
||||||
{
|
{
|
||||||
BigDecimal::of(1)->dividedBy(2, -1);
|
BigDecimal::of(1)->dividedBy(2, RoundingMode::UNNECESSARY, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -629,7 +629,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDividedByWithInvalidRoundingModeThrowsException()
|
public function testDividedByWithInvalidRoundingModeThrowsException()
|
||||||
{
|
{
|
||||||
BigDecimal::of(1)->dividedBy(2, 1, -1);
|
BigDecimal::of(1)->dividedBy(2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -664,7 +664,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
$this->setExpectedException(ArithmeticException::class);
|
$this->setExpectedException(ArithmeticException::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actual = $number->dividedBy($divisor, $scale, $roundingMode);
|
$actual = $number->dividedBy($divisor, $roundingMode, $scale);
|
||||||
|
|
||||||
if ($expected !== null) {
|
if ($expected !== null) {
|
||||||
$this->assertBigDecimalEquals($expected, $scale, $actual);
|
$this->assertBigDecimalEquals($expected, $scale, $actual);
|
||||||
@ -1139,6 +1139,7 @@ class BigDecimalTest extends AbstractTestCase
|
|||||||
[RoundingMode::UNNECESSARY, '-3.501', null, null, null],
|
[RoundingMode::UNNECESSARY, '-3.501', null, null, null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerDivideAndRemainder
|
* @dataProvider providerDivideAndRemainder
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user