| Conditions | 23 |
| Paths | 23 |
| Total Lines | 96 |
| Code Lines | 70 |
| 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 |
||
| 142 | public function adjustInvalidGmtOffsets($gmt_offset = 0) |
||
| 143 | { |
||
| 144 | //make sure $gmt_offset is int |
||
| 145 | $gmt_offset = (int) $gmt_offset; |
||
| 146 | switch ($gmt_offset) { |
||
| 147 | //-12 |
||
| 148 | case -43200: |
||
| 149 | $gmt_offset = -39600; |
||
| 150 | break; |
||
| 151 | //-11.5 |
||
| 152 | case -41400: |
||
| 153 | $gmt_offset = -39600; |
||
| 154 | break; |
||
| 155 | //-10.5 |
||
| 156 | case -37800: |
||
| 157 | $gmt_offset = -39600; |
||
| 158 | break; |
||
| 159 | //-8.5 |
||
| 160 | case -30600: |
||
| 161 | $gmt_offset = -28800; |
||
| 162 | break; |
||
| 163 | //-7.5 |
||
| 164 | case -27000: |
||
| 165 | $gmt_offset = -25200; |
||
| 166 | break; |
||
| 167 | //-6.5 |
||
| 168 | case -23400: |
||
| 169 | $gmt_offset = -21600; |
||
| 170 | break; |
||
| 171 | //-5.5 |
||
| 172 | case -19800: |
||
| 173 | $gmt_offset = -18000; |
||
| 174 | break; |
||
| 175 | //-4.5 |
||
| 176 | case -16200: |
||
| 177 | $gmt_offset = -14400; |
||
| 178 | break; |
||
| 179 | //-3.5 |
||
| 180 | case -12600: |
||
| 181 | $gmt_offset = -10800; |
||
| 182 | break; |
||
| 183 | //-2.5 |
||
| 184 | case -9000: |
||
| 185 | $gmt_offset = -7200; |
||
| 186 | break; |
||
| 187 | //-1.5 |
||
| 188 | case -5400: |
||
| 189 | $gmt_offset = -3600; |
||
| 190 | break; |
||
| 191 | //-0.5 |
||
| 192 | case -1800: |
||
| 193 | $gmt_offset = 0; |
||
| 194 | break; |
||
| 195 | //.5 |
||
| 196 | case 1800: |
||
| 197 | $gmt_offset = 3600; |
||
| 198 | break; |
||
| 199 | //1.5 |
||
| 200 | case 5400: |
||
| 201 | $gmt_offset = 7200; |
||
| 202 | break; |
||
| 203 | //2.5 |
||
| 204 | case 9000: |
||
| 205 | $gmt_offset = 10800; |
||
| 206 | break; |
||
| 207 | //3.5 |
||
| 208 | case 12600: |
||
| 209 | $gmt_offset = 14400; |
||
| 210 | break; |
||
| 211 | //7.5 |
||
| 212 | case 27000: |
||
| 213 | $gmt_offset = 28800; |
||
| 214 | break; |
||
| 215 | //8.5 |
||
| 216 | case 30600: |
||
| 217 | $gmt_offset = 31500; |
||
| 218 | break; |
||
| 219 | //10.5 |
||
| 220 | case 37800: |
||
| 221 | $gmt_offset = 39600; |
||
| 222 | break; |
||
| 223 | //11.5 |
||
| 224 | case 41400: |
||
| 225 | $gmt_offset = 43200; |
||
| 226 | break; |
||
| 227 | //12.75 |
||
| 228 | case 45900: |
||
| 229 | $gmt_offset = 46800; |
||
| 230 | break; |
||
| 231 | //13.75 |
||
| 232 | case 49500: |
||
| 233 | $gmt_offset = 50400; |
||
| 234 | break; |
||
| 235 | } |
||
| 236 | return $gmt_offset; |
||
| 237 | } |
||
| 238 | } |
||
| 239 |