| Conditions | 15 |
| Paths | 2187 |
| Total Lines | 61 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 45 | public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
||
| 46 | /** @var ISchemaWrapper $schema */ |
||
| 47 | $schema = $schemaClosure(); |
||
| 48 | |||
| 49 | if ($schema->hasTable('polls_options')) { |
||
| 50 | $table = $schema->getTable('polls_options'); |
||
| 51 | if (!$table->hasIndex('UNIQ_options')) { |
||
| 52 | $table->addUniqueIndex(['poll_id', 'poll_option_text', 'timestamp'], 'UNIQ_options'); |
||
| 53 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
|
|
|||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | if ($schema->hasTable('polls_log')) { |
||
| 58 | $table = $schema->getTable('polls_log'); |
||
| 59 | if (!$table->hasIndex('UNIQ_unprocessed')) { |
||
| 60 | $table->addUniqueIndex(['processed', 'poll_id', 'user_id', 'message_id'], 'UNIQ_unprocessed'); |
||
| 61 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | if ($schema->hasTable('polls_notif')) { |
||
| 66 | $table = $schema->getTable('polls_notif'); |
||
| 67 | if (!$table->hasIndex('UNIQ_subscription')) { |
||
| 68 | $table->addUniqueIndex(['poll_id', 'user_id'], 'UNIQ_subscription'); |
||
| 69 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | if ($schema->hasTable('polls_share')) { |
||
| 74 | $table = $schema->getTable('polls_share'); |
||
| 75 | if (!$table->hasIndex('UNIQ_shares')) { |
||
| 76 | $table->addUniqueIndex(['poll_id', 'user_id'], 'UNIQ_shares'); |
||
| 77 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | if ($schema->hasTable('polls_votes')) { |
||
| 82 | $table = $schema->getTable('polls_votes'); |
||
| 83 | if (!$table->hasIndex('UNIQ_votes')) { |
||
| 84 | $table->addUniqueIndex(['poll_id', 'user_id', 'vote_option_text'], 'UNIQ_votes'); |
||
| 85 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($schema->hasTable('polls_preferences')) { |
||
| 90 | $table = $schema->getTable('polls_preferences'); |
||
| 91 | if (!$table->hasIndex('UNIQ_preferences')) { |
||
| 92 | $table->addUniqueIndex(['user_id'], 'UNIQ_preferences'); |
||
| 93 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | if ($schema->hasTable('polls_watch')) { |
||
| 98 | $table = $schema->getTable('polls_watch'); |
||
| 99 | if (!$table->hasIndex('UNIQ_watch')) { |
||
| 100 | $table->addUniqueIndex(['poll_id', 'table'], 'UNIQ_watch'); |
||
| 101 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | |||
| 105 | return $schema; |
||
| 106 | } |
||
| 108 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.