From cf4ea0171e588fdc9d44beb705e379a20ecbd652 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 1 Jul 2014 19:43:27 +0200 Subject: Simplify code to bound integer values Suggested-by: Florian Pritz Signed-off-by: Lukas Fleischer --- web/lib/aur.inc.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'web/lib/aur.inc.php') diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index 33686968..7fa792bb 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -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); +} -- cgit v1.2.3-24-g4f1b