Completed
Push — master ( f2f236...86f141 )
by Julius
08:20 queued 10s
created

Version030702Date20200626072306::changeSchema()   B

Complexity

Conditions 8
Paths 128

Size

Total Lines 58

Duplication

Lines 18
Ratio 31.03 %

Importance

Changes 0
Metric Value
dl 18
loc 58
rs 7.4852
c 0
b 0
f 0
cc 8
nc 128
nop 3

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\Richdocuments\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\SimpleMigrationStep;
10
use OCP\Migration\IOutput;
11
12
/**
13
 * Auto-generated migration step: Please modify to your needs!
14
 */
15
class Version030702Date20200626072306 extends SimpleMigrationStep {
16
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 */
22
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23
	}
24
25
	/**
26
	 * @param IOutput $output
27
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
	 * @param array $options
29
	 * @return null|ISchemaWrapper
30
	 */
31
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34
35
		$table = $schema->getTable('richdocuments_wopi');
36
37
		if (!$table->hasColumn('template_id')) {
38
			$table->addColumn('template_id', 'integer', [
39
				'notnull' => false,
40
				'length' => 4,
41
			]);
42
		}
43
44 View Code Duplication
		if (!$table->hasColumn('hide_download')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
45
			$table->addColumn('hide_download', 'boolean', [
46
				'notnull' => true,
47
				'default' => false,
48
			]);
49
		}
50
51
		if (!$table->hasColumn('share')) {
52
			$table->addColumn('share', 'string', [
53
				'notnull' => false,
54
				'length' => 64
55
			]);
56
		}
57
58 View Code Duplication
		if (!$table->hasColumn('direct')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
59
			$table->addColumn('direct', 'boolean', [
60
				'notnull' => true,
61
				'default' => false,
62
			]);
63
		}
64 View Code Duplication
		if (!$table->hasColumn('is_remote_token')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
65
			$table->addColumn('is_remote_token', 'boolean', [
66
				'notnull' => true,
67
				'default' => false,
68
			]);
69
		}
70
71
		if (!$table->hasColumn('remote_server')) {
72
			$table->addColumn('remote_server', 'string', [
73
				'notnull' => true,
74
				'default' => '',
75
			]);
76
77
		}
78
		if (!$table->hasColumn('remote_server_token')) {
79
			$table->addColumn('remote_server_token', 'string', [
80
				'notnull' => true,
81
				'length' => 32,
82
				'default' => '',
83
			]);
84
		}
85
86
87
		return $schema;
88
	}
89
90
	/**
91
	 * @param IOutput $output
92
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
93
	 * @param array $options
94
	 */
95
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
96
	}
97
}
98