| Conditions | 10 | 
| Paths | 10 | 
| Total Lines | 49 | 
| Code Lines | 35 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
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  | 
            ||
| 4 | function icon($type, $options = "")  | 
            ||
| 5 |     { | 
            ||
| 6 | $icon = "fa-check";  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 7 | |||
| 8 | switch ($type):  | 
            ||
| 9 | case 'add':  | 
            ||
| 10 | $icon = "fa-plus";  | 
            ||
| 11 | break;  | 
            ||
| 12 | |||
| 13 | case 'edit':  | 
            ||
| 14 | $icon = "fa-pencil";  | 
            ||
| 15 | break;  | 
            ||
| 16 | |||
| 17 | case 'delete':  | 
            ||
| 18 | $icon = "fa-trash-o";  | 
            ||
| 19 | break;  | 
            ||
| 20 | |||
| 21 | case 'back':  | 
            ||
| 22 | $icon = "fa-arrow-left";  | 
            ||
| 23 | break;  | 
            ||
| 24 | |||
| 25 | case 'next':  | 
            ||
| 26 | $icon = "fa-arrow-right";  | 
            ||
| 27 | break;  | 
            ||
| 28 | |||
| 29 | case 'up':  | 
            ||
| 30 | $icon = "fa-arrow-up";  | 
            ||
| 31 | break;  | 
            ||
| 32 | |||
| 33 | case 'down':  | 
            ||
| 34 | $icon = "fa-arrow-down";  | 
            ||
| 35 | break;  | 
            ||
| 36 | |||
| 37 | case 'save':  | 
            ||
| 38 | $icon = "fa-floppy-o";  | 
            ||
| 39 | break;  | 
            ||
| 40 | |||
| 41 | case 'dashboard':  | 
            ||
| 42 | $icon = "fa-dashboard";  | 
            ||
| 43 | break;  | 
            ||
| 44 | |||
| 45 | // Print the icon parameter  | 
            ||
| 46 | default:  | 
            ||
| 47 | $icon = $type;  | 
            ||
| 48 | break;  | 
            ||
| 49 | endswitch;  | 
            ||
| 50 | |||
| 51 | return \FontAwesome::icon($icon, $options);  | 
            ||
| 52 | }  | 
            ||
| 53 | }  | 
            
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.