| Conditions | 8 |
| Paths | 17 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 8 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | 2 | public function validate($value, Field $field, Model $model = null) |
|
| 16 | { |
||
| 17 | 2 | if ($field->getValidators()[self::class] ?? false) { |
|
| 18 | 2 | $expectedFields = $field->getValidators()[self::class]; |
|
| 19 | 2 | if (!is_array($expectedFields)) { |
|
| 20 | 2 | $expectedFields = [$expectedFields]; |
|
| 21 | } |
||
| 22 | 2 | $found = false; |
|
| 23 | 2 | $data = $model->getData(); |
|
|
|
|||
| 24 | 2 | foreach ($expectedFields as $ef) { |
|
| 25 | 2 | if (array_key_exists($ef, $data) && !empty($data[$ef])) { |
|
| 26 | 2 | $found = true; |
|
| 27 | 2 | break; |
|
| 28 | } |
||
| 29 | } |
||
| 30 | 2 | if ($found && empty($value)) { |
|
| 31 | 1 | $name = $field->getName(); |
|
| 32 | 1 | throw new ValidatorException("Field $name is required when at least one of fields " . implode(',', $expectedFields) . ' are present'); |
|
| 33 | } |
||
| 34 | } |
||
| 35 | 1 | return $value; |
|
| 36 | } |
||
| 38 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.