Skip to content

Commit

Permalink
min() and max() now use variadics
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed May 22, 2015
1 parent d246c7b commit 9ab6358
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/BigDecimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public static function zero()
/**
* Returns the minimum of the given values.
*
* @param array<Decimal|number|string> An array of decimals to return the minimum value of.
* @param BigDecimal|number|string ...$values The numbers to compare.
*
* @return \Brick\Math\BigDecimal The minimum value.
* @return BigDecimal The minimum value.
*
* @throws \InvalidArgumentException If no values are given, or an invalid value is given.
*/
public static function min(array $values)
public static function min(...$values)
{
$min = null;

Expand All @@ -165,13 +165,13 @@ public static function min(array $values)
/**
* Returns the maximum of the given values.
*
* @param array<Decimal|number|string> An array of decimals to return the maximum value of.
* @param BigDecimal|number|string ...$values The numbers to compare.
*
* @return \Brick\Math\BigDecimal The maximum value.
* @return BigDecimal The maximum value.
*
* @throws \InvalidArgumentException If no values are given, or an invalid value is given.
*/
public static function max(array $values)
public static function max(...$values)
{
$max = null;

Expand Down
12 changes: 6 additions & 6 deletions src/BigInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ public static function zero()
/**
* Returns the minimum of the given values.
*
* @param array<BigInteger|integer|string> An array of integers to return the minimum value of.
* @param BigInteger|integer|string ...$values The numbers to compare.
*
* @return \Brick\Math\BigInteger The minimum value.
* @return BigInteger The minimum value.
*
* @throws \InvalidArgumentException If no values are given, or an invalid value is given.
*/
public static function min(array $values)
public static function min(...$values)
{
$min = null;

Expand All @@ -189,13 +189,13 @@ public static function min(array $values)
/**
* Returns the maximum of the given values.
*
* @param array<BigInteger|integer|string> An array of integers to return the maximum value of.
* @param BigInteger|integer|string ...$values The numbers to compare.
*
* @return \Brick\Math\BigInteger The maximum value.
* @return BigInteger The maximum value.
*
* @throws \InvalidArgumentException If no values are given, or an invalid value is given.
*/
public static function max(array $values)
public static function max(...$values)
{
$max = null;

Expand Down
8 changes: 4 additions & 4 deletions tests/BigDecimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function testZero()
*/
public function testMin(array $values, $index)
{
$this->assertTrue(BigDecimal::min($values)->isEqualTo($values[$index]));
$this->assertTrue(BigDecimal::min(...$values)->isEqualTo($values[$index]));
}

/**
Expand Down Expand Up @@ -287,7 +287,7 @@ public function providerMin()
*/
public function testMinOfZeroValuesThrowsException()
{
BigDecimal::min([]);
BigDecimal::min();
}

/**
Expand All @@ -298,7 +298,7 @@ public function testMinOfZeroValuesThrowsException()
*/
public function testMax(array $values, $index)
{
$this->assertTrue(BigDecimal::max($values)->isEqualTo($values[$index]));
$this->assertTrue(BigDecimal::max(...$values)->isEqualTo($values[$index]));
}

/**
Expand Down Expand Up @@ -331,7 +331,7 @@ public function providerMax()
*/
public function testMaxOfZeroValuesThrowsException()
{
BigDecimal::max([]);
BigDecimal::max();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/BigIntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function testZero()
*/
public function testMin(array $values, $index)
{
$this->assertTrue(BigInteger::min($values)->isEqualTo($values[$index]));
$this->assertTrue(BigInteger::min(...$values)->isEqualTo($values[$index]));
}

/**
Expand All @@ -345,7 +345,7 @@ public function providerMin()
*/
public function testMinOfZeroValuesThrowsException()
{
BigInteger::min([]);
BigInteger::min();
}

/**
Expand All @@ -356,7 +356,7 @@ public function testMinOfZeroValuesThrowsException()
*/
public function testMax(array $values, $index)
{
$this->assertTrue(BigInteger::max($values)->isEqualTo($values[$index]));
$this->assertTrue(BigInteger::max(...$values)->isEqualTo($values[$index]));
}

/**
Expand All @@ -381,7 +381,7 @@ public function providerMax()
*/
public function testMaxOfZeroValuesThrowsException()
{
BigInteger::max([]);
BigInteger::max();
}

/**
Expand Down

0 comments on commit 9ab6358

Please sign in to comment.