mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
Merge pull request #334 from joebordes/sonarqube
merge IF statement with enclosing one (sonarqube static analysis)
This commit is contained in:
commit
f7e662e3c0
@ -172,9 +172,7 @@ class Validator
|
|||||||
return $find[1];
|
return $find[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($value)) {
|
if (is_null($value) || (is_string($value) && trim($value) === '')) {
|
||||||
return false;
|
|
||||||
} elseif (is_string($value) && trim($value) === '') {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,13 +888,11 @@ class Validator
|
|||||||
} elseif (isset($cards)) {
|
} elseif (isset($cards)) {
|
||||||
// if we have cards, check our users card against only the ones we have
|
// if we have cards, check our users card against only the ones we have
|
||||||
foreach ($cards as $card) {
|
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 the card is valid, we want to stop looping
|
||||||
if (preg_match($cardRegex[$card], $value) === 1) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// loop through every card
|
// loop through every card
|
||||||
foreach ($cardRegex as $regex) {
|
foreach ($cardRegex as $regex) {
|
||||||
@ -1102,11 +1098,9 @@ class Validator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use custom label instead of field name if set
|
// Use custom label instead of field name if set
|
||||||
if (is_string($params[0])) {
|
if (is_string($params[0]) && isset($this->_labels[$param])) {
|
||||||
if (isset($this->_labels[$param])) {
|
|
||||||
$param = $this->_labels[$param];
|
$param = $this->_labels[$param];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$values[] = $param;
|
$values[] = $param;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,12 +1285,10 @@ class Validator
|
|||||||
protected function hasRule($name, $field)
|
protected function hasRule($name, $field)
|
||||||
{
|
{
|
||||||
foreach ($this->_validations as $validation) {
|
foreach ($this->_validations as $validation) {
|
||||||
if ($validation['rule'] == $name) {
|
if ($validation['rule'] == $name && in_array($field, $validation['fields'])) {
|
||||||
if (in_array($field, $validation['fields'])) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user