Completed
Pull Request — master (#90)
by Janis
06:21
created

DropOldTable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 37
ccs 10
cts 12
cp 0.8333
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getName() 0 3 1
A run() 0 8 2
1
<?php
2
/**
3
 * Nextcloud - OCR
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Janis Koehr <[email protected]>
9
 * @copyright Janis Koehr 2017
10
 */
11
12
namespace OCA\Ocr\Migration;
13
14
use OCP\IDBConnection;
15
use OCP\Migration\IOutput;
16
use OCP\Migration\IRepairStep;
17
18
class DropOldTable implements IRepairStep {
19
20
	/** @var IDBConnection */
21
	protected $connection;
22
23
	/**
24
	 * @param IDBConnection $connection
25
	 */
26 2
	public function __construct(IDBConnection $connection) {
27 2
		$this->connection = $connection;
28 2
	}
29
30
	/**
31
	 * Returns the step's name
32
	 *
33
	 * @return string
34
	 */
35
	public function getName() {
36
		return 'Drop old database table';
37
	}
38
39
	/**
40
	 * Run repair step.
41
	 * Must throw exception on error.
42
	 *
43
	 * @throws \Exception in case of failure
44
	 */
45 2
	public function run(IOutput $output) {
46 2
		$output->startProgress(1);
47 2
		if ($this->connection->tableExists('ocr_status')) {
48 1
			$this->connection->dropTable('ocr_status');
49
		}
50 2
		$output->advance(1, "Drop old database table: ocr_status");
51 2
		$output->finishProgress();
52 2
	}
53
54
}