1.2.200. Common Alternatives¶
In the following conditional structures, expressions were found that are common to both ‘then’ and ‘else’. It may be interesting, though not always possible, to put them both out of the conditional, and reduce line count. may be rewritten in :
<?php
if ($c == 5) {
$b = strtolower($b[2]);
$a++;
} else {
$b = strtolower($b[2]);
$b++;
}
?>
1.2.200.1. Suggestions¶
Collect common expressions, and move them before of after the if/then expression.
Move a prefix and suffixes to a third-party method
1.2.200.2. Specs¶
Short name |
Structures/CommonAlternatives |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Examples |
|
Available in |