1.2.762. Nested Ifthen¶
Nesting ifthen
structures increases the complexity of a method. This rules uses three levels of ifthen to signal a complex structure. When a method has such a command, it should be split into smaller methods.
<?php
function foo($a, $b) {
if ($a == 1) {
// Second level, possibly too much already
if ($b == 2) {
}
}
}
function bar($a, $b, $c) {
if ($a == 1) {
// Second level.
if ($b == 2) {
// Third level level.
if ($c == 3) {
// Too much
}
}
}
}
?>
Name |
Default |
Type |
Description |
nestedIfthen |
3 |
integer |
Maximal number of acceptable nesting of if-then structures |
See also No title for Structures/TooManyIf.
1.2.762.1. Connex PHP features¶
1.2.762.1.1. Specs¶
Short name |
Structures/NestedIfthen |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Examples |
|
Available in |