// Get the number of decimal digits for the $max
$decimal_digits = self::
getDecimalDigits($max);
// Do the same for the min and keep the higher number of decimal digits.
$decimal_digits =
max(self::
getDecimalDigits($min),
$decimal_digits);
// If $min = 1.234 and $max = 1.33 then $decimal_digits = 3
$scale =
rand($decimal_digits,
$scale);
// @see "Example #1 Calculate a random floating-point number" in
// http://php.net/manual/function.mt-getrandmax.php
$random_decimal =
$min +
mt_rand() /
mt_getrandmax() *
($max -
$min);
$values['value'
] = self::
truncateDecimal($random_decimal,
$scale);
return $values;
} /**
* Helper method to get the number of decimal digits out of a decimal number.
*
* @param int $decimal
* The number to calculate the number of decimals digits from.
*
* @return int
* The number of decimal digits.
*/