| Conditions | 15 | 
| Paths | > 20000 | 
| Total Lines | 353 | 
| Lines | 85 | 
| Ratio | 24.08 % | 
| 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 | ||
| 67 | 	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { | ||
| 68 | /** @var ISchemaWrapper $schema */ | ||
| 69 | $schema = $schemaClosure(); | ||
| 70 | |||
| 71 | 		try { | ||
| 72 | 			$circles = $schema->getTable('circle_circles'); | ||
| 73 | View Code Duplication | 			if (!$circles->hasColumn('config')) { | |
|  | |||
| 74 | $circles->addColumn( | ||
| 75 | 'config', 'integer', [ | ||
| 76 | 'notnull' => false, | ||
| 77 | 'length' => 11, | ||
| 78 | 'unsigned' => true | ||
| 79 | ] | ||
| 80 | ); | ||
| 81 | } | ||
| 82 | View Code Duplication | 			if (!$circles->hasColumn('source')) { | |
| 83 | $circles->addColumn( | ||
| 84 | 'source', 'integer', [ | ||
| 85 | 'notnull' => false, | ||
| 86 | 'length' => 5, | ||
| 87 | 'unsigned' => true | ||
| 88 | ] | ||
| 89 | ); | ||
| 90 | } | ||
| 91 | 			if (!$circles->hasColumn('instance')) { | ||
| 92 | $circles->addColumn( | ||
| 93 | 'instance', 'string', [ | ||
| 94 | 'notnull' => false, | ||
| 95 | 'default' => '', | ||
| 96 | 'length' => 255 | ||
| 97 | ] | ||
| 98 | ); | ||
| 99 | } | ||
| 100 | 			if (!$circles->hasColumn('display_name')) { | ||
| 101 | $circles->addColumn( | ||
| 102 | 'display_name', 'string', [ | ||
| 103 | 'notnull' => false, | ||
| 104 | 'default' => '', | ||
| 105 | 'length' => 127 | ||
| 106 | ] | ||
| 107 | ); | ||
| 108 | } | ||
| 109 | $circles->addIndex(['config']); | ||
| 110 | 		} catch (SchemaException $e) { | ||
| 111 | } | ||
| 112 | |||
| 113 | |||
| 114 | 		try { | ||
| 115 | 			$circles = $schema->getTable('circle_members'); | ||
| 116 | View Code Duplication | 			if (!$circles->hasColumn('single_id')) { | |
| 117 | $circles->addColumn( | ||
| 118 | 'single_id', 'string', [ | ||
| 119 | 'notnull' => false, | ||
| 120 | 'length' => 15 | ||
| 121 | ] | ||
| 122 | ); | ||
| 123 | } | ||
| 124 | View Code Duplication | 			if (!$circles->hasColumn('circle_source')) { | |
| 125 | $circles->addColumn( | ||
| 126 | 'circle_source', 'string', [ | ||
| 127 | 'notnull' => false, | ||
| 128 | 'length' => 63 | ||
| 129 | ] | ||
| 130 | ); | ||
| 131 | } | ||
| 132 | 		} catch (SchemaException $e) { | ||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | 		if (!$schema->hasTable('circle_remotes')) { | ||
| 137 | 			$table = $schema->createTable('circle_remotes'); | ||
| 138 | $table->addColumn( | ||
| 139 | 'id', 'integer', [ | ||
| 140 | 'autoincrement' => true, | ||
| 141 | 'notnull' => true, | ||
| 142 | 'length' => 4, | ||
| 143 | 'unsigned' => true, | ||
| 144 | ] | ||
| 145 | ); | ||
| 146 | $table->addColumn( | ||
| 147 | 'type', 'string', [ | ||
| 148 | 'notnull' => true, | ||
| 149 | 'length' => 15, | ||
| 150 | 'default' => 'Unknown' | ||
| 151 | ] | ||
| 152 | ); | ||
| 153 | $table->addColumn( | ||
| 154 | 'uid', 'string', [ | ||
| 155 | 'notnull' => false, | ||
| 156 | 'length' => 20, | ||
| 157 | ] | ||
| 158 | ); | ||
| 159 | $table->addColumn( | ||
| 160 | 'instance', 'string', [ | ||
| 161 | 'notnull' => false, | ||
| 162 | 'length' => 127, | ||
| 163 | ] | ||
| 164 | ); | ||
| 165 | $table->addColumn( | ||
| 166 | 'href', 'string', [ | ||
| 167 | 'notnull' => false, | ||
| 168 | 'length' => 254, | ||
| 169 | ] | ||
| 170 | ); | ||
| 171 | $table->addColumn( | ||
| 172 | 'item', 'text', [ | ||
| 173 | 'notnull' => false, | ||
| 174 | ] | ||
| 175 | ); | ||
| 176 | $table->addColumn( | ||
| 177 | 'creation', 'datetime', [ | ||
| 178 | 'notnull' => false, | ||
| 179 | ] | ||
| 180 | ); | ||
| 181 | |||
| 182 | $table->setPrimaryKey(['id']); | ||
| 183 | $table->addUniqueIndex(['instance']); | ||
| 184 | $table->addIndex(['uid']); | ||
| 185 | $table->addIndex(['href']); | ||
| 186 | } | ||
| 187 | |||
| 188 | |||
| 189 | 		if (!$schema->hasTable('circle_events')) { | ||
| 190 | 			$table = $schema->createTable('circle_events'); | ||
| 191 | $table->addColumn( | ||
| 192 | 'token', 'string', [ | ||
| 193 | 'notnull' => false, | ||
| 194 | 'length' => 63, | ||
| 195 | ] | ||
| 196 | ); | ||
| 197 | $table->addColumn( | ||
| 198 | 'event', 'text', [ | ||
| 199 | 'notnull' => false | ||
| 200 | ] | ||
| 201 | ); | ||
| 202 | $table->addColumn( | ||
| 203 | 'result', 'text', [ | ||
| 204 | 'notnull' => false | ||
| 205 | ] | ||
| 206 | ); | ||
| 207 | $table->addColumn( | ||
| 208 | 'instance', 'string', [ | ||
| 209 | 'length' => 255, | ||
| 210 | 'notnull' => false | ||
| 211 | ] | ||
| 212 | ); | ||
| 213 | $table->addColumn( | ||
| 214 | 'severity', 'integer', [ | ||
| 215 | 'length' => 3, | ||
| 216 | 'notnull' => false | ||
| 217 | ] | ||
| 218 | ); | ||
| 219 | $table->addColumn( | ||
| 220 | 'status', 'integer', [ | ||
| 221 | 'length' => 3, | ||
| 222 | 'notnull' => false | ||
| 223 | ] | ||
| 224 | ); | ||
| 225 | $table->addColumn( | ||
| 226 | 'creation', 'bigint', [ | ||
| 227 | 'length' => 14, | ||
| 228 | 'notnull' => false | ||
| 229 | ] | ||
| 230 | ); | ||
| 231 | |||
| 232 | $table->addUniqueIndex(['token', 'instance']); | ||
| 233 | } | ||
| 234 | |||
| 235 | |||
| 236 | View Code Duplication | 		if (!$schema->hasTable('circle_membership')) { | |
| 237 | 			$table = $schema->createTable('circle_membership'); | ||
| 238 | |||
| 239 | $table->addColumn( | ||
| 240 | 'circle_id', 'string', [ | ||
| 241 | 'notnull' => true, | ||
| 242 | 'length' => 15, | ||
| 243 | ] | ||
| 244 | ); | ||
| 245 | $table->addColumn( | ||
| 246 | 'single_id', 'string', [ | ||
| 247 | 'notnull' => true, | ||
| 248 | 'length' => 15, | ||
| 249 | ] | ||
| 250 | ); | ||
| 251 | $table->addColumn( | ||
| 252 | 'level', 'integer', [ | ||
| 253 | 'notnull' => true, | ||
| 254 | 'length' => 1, | ||
| 255 | 'unsigned' => true | ||
| 256 | ] | ||
| 257 | ); | ||
| 258 | $table->addColumn( | ||
| 259 | 'inheritance_first', 'string', [ | ||
| 260 | 'notnull' => true, | ||
| 261 | 'length' => 15, | ||
| 262 | ] | ||
| 263 | ); | ||
| 264 | $table->addColumn( | ||
| 265 | 'inheritance_last', 'string', [ | ||
| 266 | 'notnull' => true, | ||
| 267 | 'length' => 15, | ||
| 268 | ] | ||
| 269 | ); | ||
| 270 | $table->addColumn( | ||
| 271 | 'inheritance_depth', 'integer', [ | ||
| 272 | 'notnull' => true, | ||
| 273 | 'length' => 2, | ||
| 274 | 'unsigned' => true | ||
| 275 | ] | ||
| 276 | ); | ||
| 277 | $table->addColumn( | ||
| 278 | 'inheritance_path', 'text', [ | ||
| 279 | 'notnull' => true | ||
| 280 | ] | ||
| 281 | ); | ||
| 282 | |||
| 283 | $table->addIndex(['single_id']); | ||
| 284 | $table->addUniqueIndex(['single_id', 'circle_id']); | ||
| 285 | $table->addIndex(['inheritance_first', 'inheritance_last', 'circle_id'], 'ifilci'); | ||
| 286 | } | ||
| 287 | |||
| 288 | |||
| 289 | 		if (!$schema->hasTable('circle_mount')) { | ||
| 290 | 			$table = $schema->createTable('circle_mount'); | ||
| 291 | $table->addColumn( | ||
| 292 | 'id', 'integer', [ | ||
| 293 | 'autoincrement' => true, | ||
| 294 | 'notnull' => true, | ||
| 295 | 'length' => 11, | ||
| 296 | 'unsigned' => true, | ||
| 297 | ] | ||
| 298 | ); | ||
| 299 | $table->addColumn( | ||
| 300 | 'mount_id', 'string', [ | ||
| 301 | 'notnull' => false, | ||
| 302 | 'length' => 15 | ||
| 303 | ] | ||
| 304 | ); | ||
| 305 | $table->addColumn( | ||
| 306 | 'circle_id', 'string', [ | ||
| 307 | 'notnull' => false, | ||
| 308 | 'length' => 15 | ||
| 309 | ] | ||
| 310 | ); | ||
| 311 | $table->addColumn( | ||
| 312 | 'single_id', 'string', [ | ||
| 313 | 'notnull' => false, | ||
| 314 | 'length' => 15 | ||
| 315 | ] | ||
| 316 | ); | ||
| 317 | $table->addColumn( | ||
| 318 | 'token', 'string', [ | ||
| 319 | 'notnull' => false, | ||
| 320 | 'length' => 63 | ||
| 321 | ] | ||
| 322 | ); | ||
| 323 | $table->addColumn( | ||
| 324 | 'parent', 'integer', [ | ||
| 325 | 'notnull' => false, | ||
| 326 | 'length' => 11 | ||
| 327 | ] | ||
| 328 | ); | ||
| 329 | $table->addColumn( | ||
| 330 | 'mountpoint', 'text', [ | ||
| 331 | 'notnull' => false | ||
| 332 | ] | ||
| 333 | ); | ||
| 334 | $table->addColumn( | ||
| 335 | 'mountpoint_hash', 'string', [ | ||
| 336 | 'notnull' => false, | ||
| 337 | 'length' => 64 | ||
| 338 | ] | ||
| 339 | ); | ||
| 340 | |||
| 341 | $table->setPrimaryKey(['id']); | ||
| 342 | $table->addIndex(['circle_id', 'mount_id', 'parent', 'token'], 'cmpt'); | ||
| 343 | } | ||
| 344 | |||
| 345 | |||
| 346 | 		if (!$schema->hasTable('circle_mountpoint')) { | ||
| 347 | 			$table = $schema->createTable('circle_mountpoint'); | ||
| 348 | $table->addColumn( | ||
| 349 | 'id', 'integer', [ | ||
| 350 | 'autoincrement' => true, | ||
| 351 | 'notnull' => true, | ||
| 352 | 'length' => 11, | ||
| 353 | 'unsigned' => true, | ||
| 354 | ] | ||
| 355 | ); | ||
| 356 | $table->addColumn( | ||
| 357 | 'mount_id', 'string', [ | ||
| 358 | 'notnull' => false, | ||
| 359 | 'length' => 15 | ||
| 360 | ] | ||
| 361 | ); | ||
| 362 | $table->addColumn( | ||
| 363 | 'single_id', 'string', [ | ||
| 364 | 'notnull' => false, | ||
| 365 | 'length' => 15 | ||
| 366 | ] | ||
| 367 | ); | ||
| 368 | $table->addColumn( | ||
| 369 | 'mountpoint', 'text', [ | ||
| 370 | 'notnull' => false | ||
| 371 | ] | ||
| 372 | ); | ||
| 373 | $table->addColumn( | ||
| 374 | 'mountpoint_hash', 'string', [ | ||
| 375 | 'notnull' => false, | ||
| 376 | 'length' => 64 | ||
| 377 | ] | ||
| 378 | ); | ||
| 379 | |||
| 380 | $table->setPrimaryKey(['id']); | ||
| 381 | $table->addIndex(['mount_id', 'single_id'], 'ms'); | ||
| 382 | } | ||
| 383 | |||
| 384 | |||
| 385 | 		if (!$schema->hasTable('circle_share_locks')) { | ||
| 386 | 			$table = $schema->createTable('circle_share_locks'); | ||
| 387 | $table->addColumn( | ||
| 388 | 'id', 'integer', [ | ||
| 389 | 'autoincrement' => true, | ||
| 390 | 'notnull' => true, | ||
| 391 | 'length' => 4, | ||
| 392 | 'unsigned' => true, | ||
| 393 | ] | ||
| 394 | ); | ||
| 395 | $table->addColumn( | ||
| 396 | 'item_id', 'string', [ | ||
| 397 | 'notnull' => true, | ||
| 398 | 'length' => 15 | ||
| 399 | ] | ||
| 400 | ); | ||
| 401 | $table->addColumn( | ||
| 402 | 'circle_id', 'string', [ | ||
| 403 | 'notnull' => true, | ||
| 404 | 'length' => 15 | ||
| 405 | ] | ||
| 406 | ); | ||
| 407 | $table->addColumn( | ||
| 408 | 'instance', 'string', [ | ||
| 409 | 'notnull' => true, | ||
| 410 | 'length' => 127, | ||
| 411 | ] | ||
| 412 | ); | ||
| 413 | |||
| 414 | $table->setPrimaryKey(['id']); | ||
| 415 | $table->addUniqueIndex(['item_id', 'circle_id']); | ||
| 416 | } | ||
| 417 | |||
| 418 | return $schema; | ||
| 419 | } | ||
| 420 | |||
| 423 | 
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.