| Conditions | 6 |
| Paths | 12 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 16 | public function validate($value, array $options = [], Model $model = null) |
||
| 17 | 2 | { |
|
| 18 | 2 | $expectedFields = $options['fields']; |
|
| 19 | 2 | if (!is_array($expectedFields)) { |
|
| 20 | 1 | $expectedFields = [$expectedFields]; |
|
| 21 | } |
||
| 22 | 2 | $found = true; |
|
| 23 | 2 | $data = $model->getData(); |
|
|
|
|||
| 24 | 2 | foreach ($expectedFields as $ef) { |
|
| 25 | 2 | if (!array_key_exists($ef, $data)) { |
|
| 26 | 1 | $found = false; |
|
| 27 | 2 | break; |
|
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | 2 | if ($found && empty($value)) { |
|
| 32 | 1 | throw new ValidatorException("Field is required when all fields " . implode(',', $expectedFields) . ' are present'); |
|
| 33 | 1 | } |
|
| 34 | |||
| 35 | return $value; |
||
| 36 | 1 | } |
|
| 53 |
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.