| Conditions | 19 |
| Paths | 19 |
| Total Lines | 76 |
| Code Lines | 36 |
| Lines | 67 |
| Ratio | 88.16 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 94 | function colorForShell($color, $type) |
||
| 95 | { |
||
| 96 | //Possibilité d'améliorer la compléxité du script via des boucles etc... |
||
| 97 | if($type == 'txt') |
||
| 98 | { |
||
| 99 | View Code Duplication | if($color == 'black') |
|
| 100 | { |
||
| 101 | return 30; |
||
| 102 | } |
||
| 103 | elseif($color == 'red') |
||
| 104 | { |
||
| 105 | return 31; |
||
| 106 | } |
||
| 107 | elseif($color == 'green') |
||
| 108 | { |
||
| 109 | return 32; |
||
| 110 | } |
||
| 111 | elseif($color == 'yellow') |
||
| 112 | { |
||
| 113 | return 33; |
||
| 114 | } |
||
| 115 | elseif($color == 'blue') |
||
| 116 | { |
||
| 117 | return 34; |
||
| 118 | } |
||
| 119 | elseif($color == 'magenta') |
||
| 120 | { |
||
| 121 | return 35; |
||
| 122 | } |
||
| 123 | elseif($color == 'cyan') |
||
| 124 | { |
||
| 125 | return 36; |
||
| 126 | } |
||
| 127 | elseif($color == 'white') |
||
| 128 | { |
||
| 129 | return 37; |
||
| 130 | } |
||
| 131 | } |
||
| 132 | View Code Duplication | elseif($type == 'bg') |
|
| 133 | { |
||
| 134 | if($color == 'black') |
||
| 135 | { |
||
| 136 | return 40; |
||
| 137 | } |
||
| 138 | elseif($color == 'red') |
||
| 139 | { |
||
| 140 | return 41; |
||
| 141 | } |
||
| 142 | elseif($color == 'green') |
||
| 143 | { |
||
| 144 | return 42; |
||
| 145 | } |
||
| 146 | elseif($color == 'yellow') |
||
| 147 | { |
||
| 148 | return 43; |
||
| 149 | } |
||
| 150 | elseif($color == 'blue') |
||
| 151 | { |
||
| 152 | return 44; |
||
| 153 | } |
||
| 154 | elseif($color == 'magenta') |
||
| 155 | { |
||
| 156 | return 45; |
||
| 157 | } |
||
| 158 | elseif($color == 'cyan') |
||
| 159 | { |
||
| 160 | return 46; |
||
| 161 | } |
||
| 162 | elseif($color == 'white') |
||
| 163 | { |
||
| 164 | return 47; |
||
| 165 | } |
||
| 166 | } |
||
| 167 | |||
| 168 | return false; |
||
| 169 | } |
||
| 170 | |||
| 215 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.