| Conditions | 12 |
| Paths | 12 |
| Total Lines | 29 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 84 | private function changeFreqFromPriority($priority) |
||
| 85 | { |
||
| 86 | switch ($priority) { |
||
| 87 | case '1.0': |
||
| 88 | return self::CHANGE_FREQ_HOURLY; |
||
| 89 | case '0.9': |
||
| 90 | return self::CHANGE_FREQ_DAILY; |
||
| 91 | case '0.8': |
||
| 92 | return self::CHANGE_FREQ_DAILY; |
||
| 93 | case '0.7': |
||
| 94 | return self::CHANGE_FREQ_WEEKLY; |
||
| 95 | case '0.6': |
||
| 96 | return self::CHANGE_FREQ_WEEKLY; |
||
| 97 | case '0.5': |
||
| 98 | return self::CHANGE_FREQ_WEEKLY; |
||
| 99 | case '0.4': |
||
| 100 | return self::CHANGE_FREQ_MONTHLY; |
||
| 101 | case '0.3': |
||
| 102 | return self::CHANGE_FREQ_MONTHLY; |
||
| 103 | case '0.2': |
||
| 104 | return self::CHANGE_FREQ_YEARLY; |
||
| 105 | case '0.1': |
||
| 106 | return self::CHANGE_FREQ_YEARLY; |
||
| 107 | case '0.0': |
||
| 108 | return self::CHANGE_FREQ_NEVER; |
||
| 109 | default: |
||
| 110 | return null; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: