Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | 4 | public function validate(array $data, array $rules): array |
|
13 | { |
||
14 | 4 | $errors = []; |
|
15 | 4 | foreach ($rules as $field => $fieldRules) { |
|
16 | 4 | $result = (new Rules($fieldRules))->validate(ArrayHelper::getValueByPath($data, $field)); |
|
17 | 4 | if ($result->isValid() === false) { |
|
18 | 2 | $errors[$field] = $result->getErrors(); |
|
19 | } |
||
20 | } |
||
21 | |||
22 | 4 | return $errors; |
|
23 | } |
||
25 |