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