Reformat Validation class

This commit is contained in:
vanquang9387 2015-10-19 15:47:33 +07:00
parent af8c992655
commit 8b3bba3341

View file

@ -446,11 +446,13 @@ class Validation {
if ($places === null) {
$regex = "/^{$sign}(?:{$lnum}|{$dnum}){$exp}$/";
} elseif ($places === true) {
if (is_float($check) && floor($check) === $check) {
$check = sprintf("%.1f", $check);
}
$regex = "/^{$sign}{$dnum}{$exp}$/";
} elseif (is_numeric($places)) {
$places = '[0-9]{' . $places . '}';
$dnum = "(?:[0-9]*[\.]{$places}|{$lnum}[\.]{$places})";
@ -1028,10 +1030,10 @@ class Validation {
if (is_array($check) && isset($check['error'])) {
$check = $check['error'];
}
if ($allowNoFile) {
return in_array((int) $check, array(UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE), true);
return in_array((int)$check, [UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE], true);
}
return (int)$check === UPLOAD_ERR_OK;
}