| 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 |
||
| 230 | protected function stdDecodeValue(\Plasma\ColumnDefinitionInterface $column, string $param) { |
||
| 231 | $flags = $column->getFlags(); |
||
| 232 | |||
| 233 | if($param !== null && ($flags & \Plasma\Drivers\MySQL\FieldFlags::ZEROFILL_FLAG) === 0) { |
||
| 234 | switch($column->getType()) { |
||
| 235 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONG: |
||
|
1 ignored issue
–
show
|
|||
| 236 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 || \PHP_INT_SIZE > 4) { |
||
|
1 ignored issue
–
show
|
|||
| 237 | $param = (int) $param; |
||
| 238 | } |
||
|
1 ignored issue
–
show
|
|||
| 239 | break; |
||
|
1 ignored issue
–
show
|
|||
| 240 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_LONGLONG: |
||
|
1 ignored issue
–
show
|
|||
| 241 | if(($flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) === 0 && \PHP_INT_SIZE > 4) { |
||
|
1 ignored issue
–
show
|
|||
| 242 | $param = (int) $param; |
||
| 243 | } |
||
|
1 ignored issue
–
show
|
|||
| 244 | break; |
||
|
1 ignored issue
–
show
|
|||
| 245 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TINY: |
||
|
1 ignored issue
–
show
|
|||
| 246 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_SHORT: |
||
|
1 ignored issue
–
show
|
|||
| 247 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_INT24: |
||
|
1 ignored issue
–
show
|
|||
| 248 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_TIMESTAMP: |
||
|
1 ignored issue
–
show
|
|||
| 249 | $param = (int) $param; |
||
| 250 | break; |
||
|
1 ignored issue
–
show
|
|||
| 251 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_FLOAT: |
||
|
1 ignored issue
–
show
|
|||
| 252 | case \Plasma\Drivers\MySQL\FieldFlags::FIELD_TYPE_DOUBLE: |
||
|
1 ignored issue
–
show
|
|||
| 253 | $param = (float) $param; |
||
| 254 | break; |
||
|
1 ignored issue
–
show
|
|||
| 255 | // Other types are taken as string |
||
| 256 | } |
||
| 257 | } |
||
| 258 | |||
| 259 | return $param; |
||
| 260 | } |
||
| 262 |