| Conditions | 24 |
| Paths | 24 |
| Total Lines | 39 |
| 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 |
||
| 28 | public function icon($filename) |
||
| 29 | { |
||
| 30 | switch ($this->getFileExtension($filename)) { |
||
| 31 | case 'jpeg': |
||
| 32 | case 'jpg': |
||
| 33 | case 'png': |
||
| 34 | case 'gif': |
||
| 35 | return 'fa-file-image-o text-warning'; |
||
| 36 | case 'xls': |
||
| 37 | case 'xlsx': |
||
| 38 | return 'fa-file-excel-o text-success'; |
||
| 39 | case 'doc': |
||
| 40 | case 'docx': |
||
| 41 | return 'fa-file-word-o text-info'; |
||
| 42 | case 'ppt': |
||
| 43 | case 'pptx': |
||
| 44 | return 'fa-file-powerpoint-o text-warning'; |
||
| 45 | case 'zip': |
||
| 46 | case 'rar': |
||
| 47 | case 'tar': |
||
| 48 | case 'bz2': |
||
| 49 | case 'xz': |
||
| 50 | case 'gz': |
||
| 51 | return 'fa-file-archive-o text-success'; |
||
| 52 | case 'mp3': |
||
| 53 | return 'fa-file-audio-o text-primary'; |
||
| 54 | case 'avi': |
||
| 55 | case 'mov': |
||
| 56 | return 'fa-file-video-o text-primary'; |
||
| 57 | case 'php': |
||
| 58 | case 'html': |
||
| 59 | case 'css': |
||
| 60 | return 'fa-file-code-o text-success'; |
||
| 61 | case 'pdf': |
||
| 62 | return 'fa-file-pdf-o text-danger'; |
||
| 63 | } |
||
| 64 | |||
| 65 | return 'fa-file-o'; |
||
| 66 | } |
||
| 67 | |||
| 140 |