Conditions | 11 |
Paths | 11 |
Total Lines | 27 |
Code Lines | 25 |
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 |
||
68 | public function getCondition($schedule, $command) |
||
69 | { |
||
70 | $condition = $command['condition']; |
||
71 | $at = $command['at']; |
||
72 | switch ($condition) { |
||
73 | case 'everyMinute': |
||
74 | return $schedule->everyMinute(); |
||
75 | case 'everyFiveMinutes': |
||
76 | return $schedule->everyFiveMinutes(); |
||
77 | case 'everyTenMinutes': |
||
78 | return $schedule->everyTenMinutes(); |
||
79 | case 'everyThirtyMinutes': |
||
80 | return $schedule->everyThirtyMinutes(); |
||
81 | case 'hourly': |
||
82 | return $schedule->hourly(); |
||
83 | case 'daily': |
||
84 | return $schedule->daily(); |
||
85 | case 'dailyAt': |
||
86 | return $this->getConditionWithOption($schedule, $condition, $at); |
||
87 | case 'weekly': |
||
88 | return $schedule->weekly(); |
||
89 | case 'monthly': |
||
90 | return $schedule->monthly(); |
||
91 | case 'yearly': |
||
92 | return $schedule->yearly(); |
||
93 | default: |
||
94 | return $schedule->everyMinute(); |
||
95 | } |
||
116 |