Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Modify numberBetween() to be order agnostic #683

Merged
merged 1 commit into from
Aug 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Faker/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null)
}

/**
* Returns a random number between $min and $max
* Returns a random number between $int1 and $int2 (any order)
*
* @param integer $min default to 0
* @param integer $max defaults to 32 bit max integer, ie 2147483647
* @param integer $int1 default to 0
* @param integer $int2 defaults to 32 bit max integer, ie 2147483647
* @example 79907610
*
* @return integer
*/
public static function numberBetween($min = 0, $max = 2147483647)
public static function numberBetween($int1 = 0, $int2 = 2147483647)
{
$min = $int1 < $int2 ? $int1 : $int2;
$max = $int1 < $int2 ? $int2 : $int1;
return mt_rand($min, $max);
}

Expand Down