| Conditions | 11 | 
| Paths | 6 | 
| Total Lines | 16 | 
| Code Lines | 13 | 
| 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 | ||
| 91 | public function getGreetings() | ||
| 92 |     { | ||
| 93 |         $h = Carbon::now()->format('H'); | ||
| 94 | |||
| 95 |         if ($h >= 0 && $h < 6) { | ||
| 96 | return "<i class='fa far fa-surprise fa-2x'></i>  Wow, ini masih pagi loh "; | ||
| 97 |         } elseif ($h >= 6 && $h < 11) { | ||
| 98 | return "<i class='fa far fa-laugh-beam fa-2x'></i>  Selamat pagi "; | ||
| 99 |         } elseif ($h >= 11 && $h <= 14) { | ||
| 100 | return "<i class='fa far fa-smile-wink fa-2x'></i>  Selamat siang "; | ||
| 101 |         } elseif ($h > 14 && $h <= 16) { | ||
| 102 | return "<i class='fa far fa-smile-beam fa-2x'></i>  Selamat sore "; | ||
| 103 |         } elseif ($h >= 17 && $h < 20) { | ||
| 104 | return "<i class='fa far fa-grin-stars fa-2x'></i>  Senja yang indah ya "; | ||
| 105 |         } else { | ||
| 106 | return "<i class='fa far fa-bed fa-2x'></i>  Sudah malam, sebaiknya kamu istirahat "; | ||
| 107 | } | ||
| 117 |