Completed
Push — master ( e3be9e...9444a3 )
by Morris
73:40 queued 52:27
created

Version14000Date20180522074438   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 31
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 27 27 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * @copyright 2018 Christoph Wurst <[email protected]>
6
 *
7
 * @author 2018 Christoph Wurst <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OC\Core\Migrations;
27
28
use Closure;
29
use OCP\DB\ISchemaWrapper;
30
use OCP\Migration\IOutput;
31
use OCP\Migration\SimpleMigrationStep;
32
33 View Code Duplication
class Version14000Date20180522074438 extends SimpleMigrationStep {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
34
35
	public function changeSchema(IOutput $output, Closure $schemaClosure,
36
								 array $options): ISchemaWrapper {
37
38
		$schema = $schemaClosure();
39
40
		if (!$schema->hasTable('twofactor_providers')) {
41
			$table = $schema->createTable('twofactor_providers');
42
			$table->addColumn('provider_id', 'string',
43
				[
44
					'notnull' => true,
45
					'length' => 32,
46
				]);
47
			$table->addColumn('uid', 'string',
48
				[
49
					'notnull' => true,
50
					'length' => 64,
51
				]);
52
			$table->addColumn('enabled', 'smallint',
53
				[
54
					'notnull' => true,
55
					'length' => 1,
56
				]);
57
			$table->setPrimaryKey(['provider_id', 'uid']);
58
		}
59
60
		return $schema;
61
	}
62
63
}
64