Simplify code to bound integer values

Suggested-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-07-01 19:43:27 +02:00
parent a48739508c
commit cf4ea0171e
3 changed files with 19 additions and 20 deletions

View file

@ -584,3 +584,16 @@ function array_pkgbuild_merge($pkgbase_info, $section_info) {
}
return $pi;
}
/**
* Bound an integer value between two values
*
* @param int $n Integer value to bound
* @param int $min Lower bound
* @param int $max Upper bound
*
* @return int Bounded integer value
*/
function bound($n, $min, $max) {
return min(max($n, $min), $max);
}