Skip to content

Commit 4d8a67b

Browse files
author
midesweb
committed
implement areRulesValid with matchedStrategy
1 parent 961a0fa commit 4d8a67b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/ValidatorsFactory.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,28 @@ public function createValidators(array $rules): array
2222
}
2323

2424
return array_map(function ($rule) {
25-
return new ($this->matchedRule($rule))($rule);
25+
return new ($this->matchedStrategy($rule))($rule);
2626
}, $rules);
2727
}
2828

2929
private function areRulesValid($rules)
3030
{
3131
foreach ($rules as $rule) {
32-
$matched = false;
33-
foreach ($this->validationStrategies as $strategy) {
34-
if ($strategy::isRuleMatched($rule)) {
35-
$matched = true;
36-
break;
37-
}
38-
}
32+
$matched = $this->matchedStrategy($rule);
3933
if (!$matched) {
4034
return false;
4135
}
4236
}
4337
return true;
4438
}
4539

46-
private function matchedRule($rule)
40+
private function matchedStrategy($rule)
4741
{
4842
foreach ($this->validationStrategies as $strategy) {
4943
if ($strategy::isRuleMatched($rule)) {
5044
return $strategy;
5145
}
5246
}
47+
return null;
5348
}
5449
}

0 commit comments

Comments
 (0)