Conditions | 5 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
64 | 2 | private function fixValue(string $value) |
|
65 | { |
||
66 | 2 | if (is_numeric($value) && '0' !== $value[0]) { |
|
67 | 2 | if ((string) (int) $value === $value) { |
|
68 | 2 | return (int) $value; |
|
69 | } |
||
70 | |||
71 | 2 | return (float) $value; |
|
72 | } |
||
73 | |||
74 | 2 | if ('' === $value) { |
|
75 | 1 | return null; |
|
76 | } |
||
77 | |||
78 | 2 | return $value; |
|
79 | } |
||
80 | } |
||
81 |
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.