| Conditions | 13 |
| Paths | 1296 |
| Total Lines | 147 |
| 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 |
||
| 65 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
||
| 66 | /** @var ISchemaWrapper $schema */ |
||
| 67 | $schema = $schemaClosure(); |
||
| 68 | |||
| 69 | if ($schema->hasTable('circles_event')) { |
||
| 70 | $table = $schema->getTable('circles_event'); |
||
| 71 | if (!$table->hasColumn('updated')) { |
||
| 72 | $table->addColumn( |
||
| 73 | 'updated', 'datetime', [ |
||
| 74 | 'notnull' => false, |
||
| 75 | ] |
||
| 76 | ); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | if ($schema->hasTable('circles_member')) { |
||
| 81 | $table = $schema->getTable('circles_member'); |
||
| 82 | if (!$table->hasColumn('invited_by')) { |
||
| 83 | $table->addColumn( |
||
| 84 | 'invited_by', 'string', [ |
||
| 85 | 'notnull' => false, |
||
| 86 | 'default' => '', |
||
| 87 | 'length' => 31, |
||
| 88 | ] |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 93 | if ($schema->hasTable('circles_membership')) { |
||
| 94 | $table = $schema->getTable('circles_membership'); |
||
| 95 | if (!$table->hasColumn('config')) { |
||
| 96 | $table->addColumn( |
||
| 97 | 'config', 'integer', [ |
||
| 98 | 'notnull' => false, |
||
| 99 | 'length' => 11, |
||
| 100 | 'unsigned' => true |
||
| 101 | ] |
||
| 102 | ); |
||
| 103 | $table->addIndex(['single_id', 'config']); |
||
| 104 | } |
||
| 105 | |||
| 106 | } |
||
| 107 | |||
| 108 | if ($schema->hasTable('circles_circle')) { |
||
| 109 | $table = $schema->getTable('circles_circle'); |
||
| 110 | if (!$table->hasColumn('sanitized_name')) { |
||
| 111 | $table->addColumn( |
||
| 112 | 'sanitized_name', 'string', [ |
||
| 113 | 'notnull' => false, |
||
| 114 | 'default' => '', |
||
| 115 | 'length' => 127 |
||
| 116 | ] |
||
| 117 | ); |
||
| 118 | |||
| 119 | $table->addIndex(['sanitized_name']); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | |||
| 124 | if ($schema->hasTable('circles_membership')) { |
||
| 125 | $table = $schema->getTable('circles_membership'); |
||
| 126 | $table->changeColumn( |
||
| 127 | 'circle_id', [ |
||
| 128 | 'notnull' => true, |
||
| 129 | 'length' => 31, |
||
| 130 | ] |
||
| 131 | ); |
||
| 132 | $table->changeColumn( |
||
| 133 | 'single_id', [ |
||
| 134 | 'notnull' => true, |
||
| 135 | 'length' => 31, |
||
| 136 | ] |
||
| 137 | ); |
||
| 138 | $table->changeColumn( |
||
| 139 | 'inheritance_first', [ |
||
| 140 | 'notnull' => true, |
||
| 141 | 'length' => 31, |
||
| 142 | ] |
||
| 143 | ); |
||
| 144 | $table->changeColumn( |
||
| 145 | 'inheritance_last', [ |
||
| 146 | 'notnull' => true, |
||
| 147 | 'length' => 31, |
||
| 148 | ] |
||
| 149 | ); |
||
| 150 | } |
||
| 151 | |||
| 152 | |||
| 153 | if ($schema->hasTable('circles_mount')) { |
||
| 154 | $table = $schema->getTable('circles_mount'); |
||
| 155 | $table->changeColumn( |
||
| 156 | 'mount_id', [ |
||
| 157 | 'notnull' => true, |
||
| 158 | 'length' => 31, |
||
| 159 | ] |
||
| 160 | ); |
||
| 161 | $table->changeColumn( |
||
| 162 | 'circle_id', [ |
||
| 163 | 'notnull' => true, |
||
| 164 | 'length' => 31, |
||
| 165 | ] |
||
| 166 | ); |
||
| 167 | $table->changeColumn( |
||
| 168 | 'single_id', [ |
||
| 169 | 'notnull' => true, |
||
| 170 | 'length' => 31, |
||
| 171 | ] |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | |||
| 175 | |||
| 176 | if ($schema->hasTable('circles_mountpoint')) { |
||
| 177 | $table = $schema->getTable('circles_mountpoint'); |
||
| 178 | $table->changeColumn( |
||
| 179 | 'mount_id', [ |
||
| 180 | 'notnull' => true, |
||
| 181 | 'length' => 31, |
||
| 182 | ] |
||
| 183 | ); |
||
| 184 | $table->changeColumn( |
||
| 185 | 'single_id', [ |
||
| 186 | 'notnull' => true, |
||
| 187 | 'length' => 31, |
||
| 188 | ] |
||
| 189 | ); |
||
| 190 | } |
||
| 191 | |||
| 192 | |||
| 193 | if ($schema->hasTable('circles_share_lock')) { |
||
| 194 | $table = $schema->getTable('circles_share_lock'); |
||
| 195 | $table->changeColumn( |
||
| 196 | 'item_id', [ |
||
| 197 | 'notnull' => true, |
||
| 198 | 'length' => 31, |
||
| 199 | ] |
||
| 200 | ); |
||
| 201 | $table->changeColumn( |
||
| 202 | 'circle_id', [ |
||
| 203 | 'notnull' => true, |
||
| 204 | 'length' => 31, |
||
| 205 | ] |
||
| 206 | ); |
||
| 207 | } |
||
| 208 | |||
| 209 | |||
| 210 | return $schema; |
||
| 211 | } |
||
| 212 | |||
| 215 |