| Conditions | 20 |
| Paths | 1 |
| Total Lines | 87 |
| Code Lines | 48 |
| 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 __construct() { |
||
| 46 | parent::__construct('core'); |
||
| 47 | |||
| 48 | $container = $this->getContainer(); |
||
| 49 | |||
| 50 | $container->registerService('defaultMailAddress', function () { |
||
| 51 | return Util::getDefaultEmailAddress('lostpassword-noreply'); |
||
| 52 | }); |
||
| 53 | |||
| 54 | $server = $container->getServer(); |
||
| 55 | $eventDispatcher = $server->getEventDispatcher(); |
||
| 56 | |||
| 57 | $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
||
| 58 | function(GenericEvent $event) use ($container) { |
||
| 59 | /** @var MissingIndexInformation $subject */ |
||
| 60 | $subject = $event->getSubject(); |
||
| 61 | |||
| 62 | $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
||
| 63 | |||
| 64 | if ($schema->hasTable('share')) { |
||
| 65 | $table = $schema->getTable('share'); |
||
| 66 | |||
| 67 | if (!$table->hasIndex('share_with_index')) { |
||
| 68 | $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
||
| 69 | } |
||
| 70 | if (!$table->hasIndex('parent_index')) { |
||
| 71 | $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
||
| 72 | } |
||
| 73 | if (!$table->hasIndex('owner_index')) { |
||
| 74 | $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
||
| 75 | } |
||
| 76 | if (!$table->hasIndex('initiator_index')) { |
||
| 77 | $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | if ($schema->hasTable('filecache')) { |
||
| 82 | $table = $schema->getTable('filecache'); |
||
| 83 | |||
| 84 | if (!$table->hasIndex('fs_mtime')) { |
||
| 85 | $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($schema->hasTable('twofactor_providers')) { |
||
| 90 | $table = $schema->getTable('twofactor_providers'); |
||
| 91 | |||
| 92 | if (!$table->hasIndex('twofactor_providers_uid')) { |
||
| 93 | $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | if ($schema->hasTable('login_flow_v2')) { |
||
| 98 | $table = $schema->getTable('login_flow_v2'); |
||
| 99 | |||
| 100 | if (!$table->hasIndex('poll_token')) { |
||
| 101 | $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
||
| 102 | } |
||
| 103 | if (!$table->hasIndex('login_token')) { |
||
| 104 | $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
||
| 105 | } |
||
| 106 | if (!$table->hasIndex('timestamp')) { |
||
| 107 | $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($schema->hasTable('whats_new')) { |
||
| 112 | $table = $schema->getTable('whats_new'); |
||
| 113 | |||
| 114 | if (!$table->hasIndex('version')) { |
||
| 115 | $subject->addHintForMissingSubject($table->getName(), 'version'); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | if ($schema->hasTable('cards')) { |
||
| 120 | $table = $schema->getTable('cards'); |
||
| 121 | |||
| 122 | if (!$table->hasIndex('cards_abid')) { |
||
| 123 | $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | if ($schema->hasTable('cards_properties')) { |
||
| 128 | $table = $schema->getTable('cards_properties'); |
||
| 129 | |||
| 130 | if (!$table->hasIndex('cards_prop_abid')) { |
||
| 131 | $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
||
| 132 | } |
||
| 138 |