Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 1 | public function validate(FieldInterface $field, InputModel $model, InputValidation $validation) |
|
40 | { |
||
41 | 1 | $input = $model->getInput($field); |
|
42 | |||
43 | 1 | if ($input === null) { |
|
44 | 1 | return; // no input |
|
45 | } |
||
46 | |||
47 | 1 | if ($this->parser->parseInput($input) === null) { |
|
|
|||
48 | 1 | $model->setError($field, strtr($this->error, ["field" => $validation->getLabel($field)])); |
|
49 | } |
||
50 | 1 | } |
|
51 | } |
||
52 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.