Skip to content

Commit 2fbe056

Browse files
committed
Modify numberBetween() to be order agnostic
1 parent f8fd1fc commit 2fbe056

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Faker/Provider/Base.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,18 @@ public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null)
121121
}
122122

123123
/**
124-
* Returns a random number between $min and $max
124+
* Returns a random number between $int1 and $int2 (any order)
125125
*
126-
* @param integer $min default to 0
127-
* @param integer $max defaults to 32 bit max integer, ie 2147483647
126+
* @param integer $int1 default to 0
127+
* @param integer $int2 defaults to 32 bit max integer, ie 2147483647
128128
* @example 79907610
129129
*
130130
* @return integer
131131
*/
132-
public static function numberBetween($min = 0, $max = 2147483647)
132+
public static function numberBetween($int1 = 0, $int2 = 2147483647)
133133
{
134+
$min = $int1 < $int2 ? $int1 : $int2;
135+
$max = $int1 < $int2 ? $int2 : $int1;
134136
return mt_rand($min, $max);
135137
}
136138

0 commit comments

Comments
 (0)