| Conditions | 3 |
| Paths | 4 |
| Total Lines | 54 |
| Code Lines | 36 |
| 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 |
||
| 39 | public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
||
| 40 | /** @var Schema $schema */ |
||
| 41 | $schema = $schemaClosure(); |
||
| 42 | |||
| 43 | if (!$schema->hasTable('personal_sections')) { |
||
| 44 | $table = $schema->createTable('personal_sections'); |
||
| 45 | |||
| 46 | $table->addColumn('id', Type::STRING, [ |
||
| 47 | 'notnull' => false, |
||
| 48 | 'length' => 64, |
||
| 49 | ]); |
||
| 50 | $table->addColumn('class', Type::STRING, [ |
||
| 51 | 'notnull' => true, |
||
| 52 | 'length' => 255, |
||
| 53 | ]); |
||
| 54 | $table->addColumn('priority', Type::INTEGER, [ |
||
| 55 | 'notnull' => true, |
||
| 56 | 'length' => 6, |
||
| 57 | 'default' => 0, |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $table->setPrimaryKey(['id'], 'personal_sections_id_index'); |
||
| 61 | $table->addUniqueIndex(['class'], 'personal_sections_class'); |
||
| 62 | } |
||
| 63 | |||
| 64 | if (!$schema->hasTable('personal_settings')) { |
||
| 65 | $table = $schema->createTable('personal_settings'); |
||
| 66 | |||
| 67 | $table->addColumn('id', Type::INTEGER, [ |
||
| 68 | 'autoincrement' => true, |
||
| 69 | 'notnull' => true, |
||
| 70 | 'length' => 20, |
||
| 71 | ]); |
||
| 72 | $table->addColumn('class', Type::STRING, [ |
||
| 73 | 'notnull' => true, |
||
| 74 | 'length' => 255, |
||
| 75 | ]); |
||
| 76 | $table->addColumn('section', Type::STRING, [ |
||
| 77 | 'notnull' => false, |
||
| 78 | 'length' => 64, |
||
| 79 | ]); |
||
| 80 | $table->addColumn('priority', Type::INTEGER, [ |
||
| 81 | 'notnull' => true, |
||
| 82 | 'length' => 6, |
||
| 83 | 'default' => 0, |
||
| 84 | ]); |
||
| 85 | |||
| 86 | $table->setPrimaryKey(['id'], 'personal_settings_id_index'); |
||
| 87 | $table->addUniqueIndex(['class'], 'personal_settings_class'); |
||
| 88 | $table->addIndex(['section'], 'personal_settings_section'); |
||
| 89 | } |
||
| 90 | |||
| 91 | return $schema; |
||
| 92 | } |
||
| 93 | } |
||
| 94 |