|
|
@@ -268,4 +268,47 @@ class V {
|
|
|
return !empty($value);
|
|
|
}
|
|
|
|
|
|
+ public static function filterInteger($value) {// An integer or string with integer value
|
|
|
+ if (is_int($value)) {
|
|
|
+ return true;
|
|
|
+ } else if (is_string($value)) {
|
|
|
+ if ((string)(int)$value === $value) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public static function filterNegativeInteger($value) {// An integer containing only negative values (..,-2,-1)
|
|
|
+ if (V::filterInteger($value)) {
|
|
|
+ if (intval($value) < 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public static function filterNonNegativeInteger($value) {// An integer containing only non-negative values (0,1,2,..)
|
|
|
+ if (V::filterInteger($value)) {
|
|
|
+ if (intval($value) >= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public static function filterNonPositiveInteger($value) {// An integer containing only non-positive values (..,-2,-1,0)
|
|
|
+ if (V::filterInteger($value)) {
|
|
|
+ if (intval($value) <= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public static function filterPositiveInteger($value) {// An integer containing only positive values (1,2,..)
|
|
|
+ if (V::filterInteger($value)) {
|
|
|
+ if (intval($value) > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|