merge IF statement with enclosing one (sonarqube static analysis)

This commit is contained in:
joebordes 2021-05-12 21:21:46 +02:00
parent 81515dcc95
commit 6b3c5ae608

View File

@ -172,9 +172,7 @@ class Validator
return $find[1];
}
if (is_null($value)) {
return false;
} elseif (is_string($value) && trim($value) === '') {
if (is_null($value) || (is_string($value) && trim($value) === '')) {
return false;
}
@ -890,13 +888,11 @@ class Validator
} elseif (isset($cards)) {
// if we have cards, check our users card against only the ones we have
foreach ($cards as $card) {
if (in_array($card, array_keys($cardRegex))) {
if (in_array($card, array_keys($cardRegex)) && preg_match($cardRegex[$card], $value) === 1) {
// if the card is valid, we want to stop looping
if (preg_match($cardRegex[$card], $value) === 1) {
return true;
}
}
}
} else {
// loop through every card
foreach ($cardRegex as $regex) {
@ -1102,11 +1098,9 @@ class Validator
}
}
// Use custom label instead of field name if set
if (is_string($params[0])) {
if (isset($this->_labels[$param])) {
if (is_string($params[0]) && isset($this->_labels[$param])) {
$param = $this->_labels[$param];
}
}
$values[] = $param;
}
@ -1291,12 +1285,10 @@ class Validator
protected function hasRule($name, $field)
{
foreach ($this->_validations as $validation) {
if ($validation['rule'] == $name) {
if (in_array($field, $validation['fields'])) {
if ($validation['rule'] == $name && in_array($field, $validation['fields'])) {
return true;
}
}
}
return false;
}