| Conditions | 15 |
| Paths | 12 |
| Total Lines | 30 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 240 |
| 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 |
||
| 255 | protected function stdDecodeValue(\Plasma\ColumnDefinitionInterface $column, string $param) { |
||
| 256 | $flags = $column->getFlags(); |
||
| 257 | |||
| 258 | if($param !== null && ($flags & \Plasma\Drivers\MySQL\FieldFlags::ZEROFILL_FLAG) === 0) { |
||
| 259 | switch($column->getType()) { |
||
| 260 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONG: |
||
|
1 ignored issue
–
show
|
|||
| 261 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 || \PHP_INT_SIZE > 4) { |
||
|
1 ignored issue
–
show
|
|||
| 262 | $param = (int) $param; |
||
| 263 | } |
||
|
1 ignored issue
–
show
|
|||
| 264 | break; |
||
|
1 ignored issue
–
show
|
|||
| 265 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONGLONG: |
||
|
1 ignored issue
–
show
|
|||
| 266 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 && \PHP_INT_SIZE > 4) { |
||
|
1 ignored issue
–
show
|
|||
| 267 | $param = (int) $param; |
||
| 268 | } |
||
|
1 ignored issue
–
show
|
|||
| 269 | break; |
||
|
1 ignored issue
–
show
|
|||
| 270 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TINY: |
||
|
1 ignored issue
–
show
|
|||
| 271 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_SHORT: |
||
|
1 ignored issue
–
show
|
|||
| 272 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_INT24: |
||
|
1 ignored issue
–
show
|
|||
| 273 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TIMESTAMP: |
||
|
1 ignored issue
–
show
|
|||
| 274 | $param = (int) $param; |
||
| 275 | break; |
||
|
1 ignored issue
–
show
|
|||
| 276 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_FLOAT: |
||
|
1 ignored issue
–
show
|
|||
| 277 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_DOUBLE: |
||
|
1 ignored issue
–
show
|
|||
| 278 | $param = (float) $param; |
||
| 279 | break; |
||
|
1 ignored issue
–
show
|
|||
| 280 | // Other types are taken as string |
||
| 281 | } |
||
| 282 | } |
||
| 283 | |||
| 284 | return $param; |
||
| 285 | } |
||
| 287 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.