| Conditions | 11 |
| Paths | 8 |
| Total Lines | 27 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 11 |
| 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 |
||
| 24 | 7 | static function decode(\Plasma\ColumnDefinitionInterface $column, $param) { |
|
| 25 | 7 | $type = $column->getType(); |
|
| 26 | 7 | $flags = $column->getFlags(); |
|
| 27 | |||
| 28 | 7 | if($param !== null && ($flags & \Plasma\Drivers\MySQL\FieldFlags::ZEROFILL_FLAG) === 0) { |
|
| 29 | switch(true) { |
||
| 30 | 7 | case ($type === 'LONG'): |
|
|
1 ignored issue
–
show
|
|||
| 31 | 1 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 || \PHP_INT_SIZE > 4) { |
|
| 32 | 1 | $param = (int) $param; |
|
| 33 | } |
||
|
1 ignored issue
–
show
|
|||
| 34 | 1 | break; |
|
|
1 ignored issue
–
show
|
|||
| 35 | 7 | case ($type === 'LONGLONG'): |
|
|
1 ignored issue
–
show
|
|||
| 36 | 1 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 && \PHP_INT_SIZE > 4) { |
|
| 37 | 1 | $param = (int) $param; |
|
| 38 | } |
||
| 39 | 1 | break; |
|
|
1 ignored issue
–
show
|
|||
| 40 | 7 | case static::isTypeTinyShortInt($type): |
|
|
1 ignored issue
–
show
|
|||
| 41 | 1 | $param = (int) $param; |
|
| 42 | 1 | break; |
|
|
1 ignored issue
–
show
|
|||
| 43 | 6 | case static::isTypeFloat($type): |
|
|
1 ignored issue
–
show
|
|||
| 44 | 1 | $param = (float) $param; |
|
| 45 | 1 | break; |
|
| 46 | // Other types are taken as string |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 7 | return $param; |
|
| 51 | } |
||
| 71 |