Merge pull request #16931 from civicrm/5.24
[civicrm-core.git] / CRM / Utils / Rule.php
index cbe4ed8f8291617583981eebf006b776a14a457f..46402eebdca70c8a1b2c970751974d08aa1600ec 100644 (file)
@@ -449,7 +449,7 @@ class CRM_Utils_Rule {
    */
   public static function positiveInteger($value) {
     if (is_int($value)) {
-      return ($value < 0) ? FALSE : TRUE;
+      return !($value < 0);
     }
 
     // CRM-13460
@@ -458,11 +458,7 @@ class CRM_Utils_Rule {
       return FALSE;
     }
 
-    if (preg_match('/^\d+$/', $value)) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return (bool) preg_match('/^\d+$/', $value);
   }
 
   /**
@@ -492,7 +488,7 @@ class CRM_Utils_Rule {
       return FALSE;
     }
 
-    return preg_match('/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/', $value) ? TRUE : FALSE;
+    return (bool) preg_match('/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/', $value);
   }
 
   /**
@@ -513,7 +509,7 @@ class CRM_Utils_Rule {
    * @return bool
    */
   public static function alphanumeric($value) {
-    return preg_match('/^[a-zA-Z0-9_-]*$/', $value) ? TRUE : FALSE;
+    return (bool) preg_match('/^[a-zA-Z0-9_-]*$/', $value);
   }
 
   /**
@@ -523,7 +519,7 @@ class CRM_Utils_Rule {
    * @return bool
    */
   public static function numberOfDigit($value, $noOfDigit) {
-    return preg_match('/^\d{' . $noOfDigit . '}$/', $value) ? TRUE : FALSE;
+    return (bool) preg_match('/^\d{' . $noOfDigit . '}$/', $value);
   }
 
   /**
@@ -605,7 +601,7 @@ class CRM_Utils_Rule {
     // Allow values such as -0, 1.024555, -.1
     // We need to support multiple decimal places here, not just the number allowed by locale
     //  otherwise tax calculations break when you want the inclusive amount to be a round number (eg. £10 inc. VAT requires 8.333333333 here).
-    return preg_match('/(^-?\d+\.?\d*$)|(^-?\.\d+$)/', $value) ? TRUE : FALSE;
+    return (bool) preg_match('/(^-?\d+\.?\d*$)|(^-?\.\d+$)/', $value);
   }
 
   /**