ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LookupRefValidations.php
Go to the documentation of this file.
1<?php
2
4
7
9{
13 public static function validateInt($value): int
14 {
15 if (!is_numeric($value)) {
16 if (Functions::isError($value)) {
17 throw new Exception($value);
18 }
19
20 throw new Exception(Functions::VALUE());
21 }
22
23 return (int) floor((float) $value);
24 }
25
29 public static function validatePositiveInt($value, bool $allowZero = true): int
30 {
31 $value = self::validateInt($value);
32
33 if (($allowZero === false && $value <= 0) || $value < 0) {
34 throw new Exception(Functions::VALUE());
35 }
36
37 return $value;
38 }
39}
An exception for terminatinating execution or to throw for unit testing.