| Conditions | 7 |
| Paths | 30 |
| Total Lines | 58 |
| Code Lines | 39 |
| 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 |
||
| 45 | public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
||
| 46 | /** @var ISchemaWrapper $schema */ |
||
| 47 | $schema = $schemaClosure(); |
||
| 48 | if ($schema->hasTable('polls_polls')) { |
||
| 49 | $table = $schema->getTable('polls_polls'); |
||
| 50 | if (!$table->hasColumn('allow_comment')) { |
||
| 51 | $table->addColumn('allow_comment', 'integer', [ |
||
| 52 | 'length' => 11, |
||
| 53 | 'notnull' => true, |
||
| 54 | 'default' => 1 |
||
| 55 | ]); |
||
| 56 | } |
||
| 57 | if (!$table->hasColumn('hide_booked_up')) { |
||
| 58 | $table->addColumn('hide_booked_up', 'integer', [ |
||
| 59 | 'length' => 11, |
||
| 60 | 'notnull' => true, |
||
| 61 | 'default' => 1 |
||
| 62 | ]); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($schema->hasTable('polls_options')) { |
||
| 67 | $table = $schema->getTable('polls_options'); |
||
| 68 | |||
| 69 | if (!$table->hasColumn('duration')) { |
||
| 70 | $table->addColumn('duration', 'integer', [ |
||
| 71 | 'length' => 11, |
||
| 72 | 'notnull' => true, |
||
| 73 | 'default' => 0 |
||
| 74 | ]); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | if (!$schema->hasTable('polls_watch')) { |
||
| 79 | $table = $schema->createTable('polls_watch'); |
||
| 80 | $table->addColumn('id', 'integer', [ |
||
| 81 | 'autoincrement' => true, |
||
| 82 | 'notnull' => true, |
||
| 83 | ]); |
||
| 84 | $table->addColumn('table', 'string', [ |
||
| 85 | 'length' => 64, |
||
| 86 | 'notnull' => true, |
||
| 87 | 'default' => '' |
||
| 88 | ]); |
||
| 89 | $table->addColumn('poll_id', 'integer', [ |
||
| 90 | 'length' => 11, |
||
| 91 | 'notnull' => true, |
||
| 92 | 'default' => 0 |
||
| 93 | ]); |
||
| 94 | $table->addColumn('updated', 'integer', [ |
||
| 95 | 'length' => 11, |
||
| 96 | 'notnull' => true, |
||
| 97 | 'default' => 0 |
||
| 98 | ]); |
||
| 99 | $table->setPrimaryKey(['id']); |
||
| 100 | } |
||
| 101 | |||
| 102 | return $schema; |
||
| 103 | } |
||
| 105 |