summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-07-01 19:43:27 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-07-01 19:46:16 +0200
commitcf4ea0171e588fdc9d44beb705e379a20ecbd652 (patch)
treec06049077e9761a3961ab45d3b3d093c4f3cb472 /web/lib/aur.inc.php
parenta48739508c8b9de9fb0af30b8b656c5f19378170 (diff)
downloadaur-cf4ea0171e588fdc9d44beb705e379a20ecbd652.tar.gz
aur-cf4ea0171e588fdc9d44beb705e379a20ecbd652.tar.xz
Simplify code to bound integer values
Suggested-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php13
1 files changed, 13 insertions, 0 deletions
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);
+}