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