*/
public static function positiveInteger($value) {
if (is_int($value)) {
- return ($value < 0) ? FALSE : TRUE;
+ return !($value < 0);
}
// CRM-13460
return FALSE;
}
- if (preg_match('/^\d+$/', $value)) {
- return TRUE;
- }
-
- return FALSE;
+ return (bool) preg_match('/^\d+$/', $value);
}
/**
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);
}
/**
* @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);
}
/**
* @return bool
*/
public static function numberOfDigit($value, $noOfDigit) {
- return preg_match('/^\d{' . $noOfDigit . '}$/', $value) ? TRUE : FALSE;
+ return (bool) preg_match('/^\d{' . $noOfDigit . '}$/', $value);
}
/**
// 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);
}
/**