| Conditions | 14 |
| Paths | 128 |
| Total Lines | 39 |
| Code Lines | 17 |
| 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 |
||
| 118 | public function update($previousVersion = false) { |
||
| 119 | $ret = true; |
||
| 120 | |||
| 121 | if (!$previousVersion) { |
||
|
|
|||
| 122 | $previousVersion = '0.0.1'; |
||
| 123 | } |
||
| 124 | |||
| 125 | // less than 1.0.2 |
||
| 126 | if ($ret && version_compare($previousVersion, '1.0.2', '<')) { |
||
| 127 | $ret = FieldEntry_Relationship::update_102(); |
||
| 128 | } |
||
| 129 | |||
| 130 | // less than 1.0.3 |
||
| 131 | if ($ret && version_compare($previousVersion, '1.0.3', '<')) { |
||
| 132 | $ret = FieldEntry_Relationship::update_103(); |
||
| 133 | } |
||
| 134 | |||
| 135 | // less than 2.0.0.beta5 |
||
| 136 | if ($ret && version_compare($previousVersion, '2.0.0.beta5', '<')) { |
||
| 137 | $ret = FieldEntry_Relationship::update_200(); |
||
| 138 | } |
||
| 139 | |||
| 140 | // less than 2.0.0.beta6 |
||
| 141 | if ($ret && version_compare($previousVersion, '2.0.0.beta6', '<')) { |
||
| 142 | $ret = FieldReverse_Relationship::update_200(); |
||
| 143 | } |
||
| 144 | |||
| 145 | // less than 2.0.0.beta8 |
||
| 146 | if ($ret && version_compare($previousVersion, '2.0.0.beta8', '<')) { |
||
| 147 | $ret = FieldEntry_Relationship::update_2008(); |
||
| 148 | } |
||
| 149 | |||
| 150 | // less than 2.1.0 |
||
| 151 | if ($ret && version_compare($previousVersion, '2.1.0', '<')) { |
||
| 152 | $ret = FieldReverse_Relationship::update_210(); |
||
| 153 | } |
||
| 154 | |||
| 155 | return $ret; |
||
| 156 | } |
||
| 157 | |||
| 165 | } |
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: