DropOldTable   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 41
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getName() 0 3 1
A run() 0 12 3
1
<?php
2
3
/**
4
 * Nextcloud - OCR
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
namespace OCA\Ocr\Migration;
12
13
use OCP\IDBConnection;
14
use OCP\Migration\IOutput;
15
use OCP\Migration\IRepairStep;
16
17
18
class DropOldTable implements IRepairStep {
19
20
    /** @var IDBConnection */
21
    protected $connection;
22
23
    /**
24
     *
25
     * @param IDBConnection $connection            
26
     */
27 2
    public function __construct(IDBConnection $connection) {
28 2
        $this->connection = $connection;
29 2
    }
30
31
    /**
32
     * Returns the step's name
33
     * 
34
     * @return string
35
     */
36
    public function getName() {
37
        return 'Drop old database table';
38
    }
39
40
    /**
41
     * Run repair step.
42
     * Must throw exception on error.
43
     * 
44
     * @throws \Exception in case of failure
45
     */
46 2
    public function run(IOutput $output) {
47 2
        $output->startProgress(1);
48 2
        if ($this->connection->tableExists('ocr_jobs')) {
49 1
            $this->connection->dropTable('ocr_jobs');
50
        }
51
        // still needed for downwards compatibility
52 2
        if ($this->connection->tableExists('ocr_status')) {
53 1
            $this->connection->dropTable('ocr_status');
54
        }
55 2
        $output->advance(1, "Drop old database table: ocr_jobs");
56 2
        $output->finishProgress();
57
    }
58
}