| Conditions | 12 |
| Paths | 12 |
| Total Lines | 24 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 35 | 12 | public function generate(string $dbalType, Column $column): string |
|
| 36 | { |
||
| 37 | 8 | switch ($dbalType) { |
|
| 38 | 4 | case DBALTypes::SMALLINT: |
|
| 39 | 4 | case DBALTypes::INTEGER: |
|
| 40 | 4 | case DBALTypes::BIGINT: |
|
| 41 | 4 | case DBALTypes::MEDIUMINT: |
|
| 42 | 4 | case DBALTypes::TINYINT: |
|
| 43 | 4 | case DBALTypes::DECIMAL: |
|
| 44 | 4 | case DBALTypes::FLOAT: |
|
| 45 | 4 | case DBALTypes::DOUBLE: |
|
| 46 | 3 | $default = $column->getDefault(); |
|
| 47 | 3 | break; |
|
| 48 | 3 | case DBALTypes::BOOLEAN: |
|
| 49 | 3 | $default = $this->booleanField->makeDefault($column); |
|
| 50 | 3 | break; |
|
| 51 | 2 | case DBALTypes::DATETIME_MUTABLE: |
|
| 52 | 2 | case DBALTypes::TIMESTAMP: |
|
| 53 | 3 | return $this->datetimeField->makeDefault($column); |
|
| 54 | default: |
||
| 55 | 3 | $default = $this->decorator->columnDefaultToString($column->getDefault()); |
|
|
|
|||
| 56 | } |
||
| 57 | |||
| 58 | 9 | return $this->decorator->decorate(ColumnModifier::DEFAULT, [$default]); |
|
| 59 | } |
||
| 61 |