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 |
||
102 | public function getGreetings() |
||
103 | { |
||
104 | $h = Carbon::now()->format('H'); |
||
105 | |||
106 | if ($h >= 0 && $h < 6) { |
||
107 | return "<i class='fa far fa-surprise fa-2x'></i> Wow, ini masih pagi loh "; |
||
108 | } elseif ($h >= 6 && $h < 11) { |
||
109 | return "<i class='fa far fa-laugh-beam fa-2x'></i> Selamat pagi "; |
||
110 | } elseif ($h >= 11 && $h <= 14) { |
||
111 | return "<i class='fa far fa-smile-wink fa-2x'></i> Selamat siang "; |
||
112 | } elseif ($h > 14 && $h <= 16) { |
||
113 | return "<i class='fa far fa-smile-beam fa-2x'></i> Selamat sore "; |
||
114 | } elseif ($h >= 17 && $h < 20) { |
||
115 | return "<i class='fa far fa-grin-stars fa-2x'></i> Senja yang indah ya "; |
||
116 | } else { |
||
117 | return "<i class='fa far fa-bed fa-2x'></i> Sudah malam, sebaiknya kamu istirahat "; |
||
118 | } |
||
141 |