DeleteDuplicates::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 * @author René Gieling <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 *  This program is free software: you can redistribute it and/or modify
11
 *  it under the terms of the GNU Affero General Public License as
12
 *  published by the Free Software Foundation, either version 3 of the
13
 *  License, or (at your option) any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU Affero General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU Affero General Public License
21
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
26
namespace OCA\Polls\Migration;
27
28
use OCA\Polls\Db\LogMapper;
29
use OCA\Polls\Db\OptionMapper;
30
use OCA\Polls\Db\PreferencesMapper;
31
use OCA\Polls\Db\ShareMapper;
32
use OCA\Polls\Db\SubscriptionMapper;
33
use OCA\Polls\Db\VoteMapper;
34
use OCP\Migration\IRepairStep;
35
use OCP\Migration\IOutput;
36
37
class DeleteDuplicates implements IRepairStep {
38
	/** @var LogMapper */
39
	private $logMapper;
40
41
	/** @var OptionMapper */
42
	private $optionMapper;
43
44
	/** @var PreferencesMapper */
45
	private $preferencesMapper;
46
47
	/** @var ShareMapper */
48
	private $shareMapper;
49
50
	/** @var SubscriptionMapper */
51
	private $subscriptionMapper;
52
53
	/** @var VoteMapper */
54
	private $voteMapper;
55
56
	public function __construct(
57
		LogMapper $logMapper,
58
		OptionMapper $optionMapper,
59
		PreferencesMapper $preferencesMapper,
60
		ShareMapper $shareMapper,
61
		SubscriptionMapper $subscriptionMapper,
62
		VoteMapper $voteMapper
63
	) {
64
		$this->logMapper = $logMapper;
65
		$this->optionMapper = $optionMapper;
66
		$this->preferencesMapper = $preferencesMapper;
67
		$this->shareMapper = $shareMapper;
68
		$this->subscriptionMapper = $subscriptionMapper;
69
		$this->voteMapper = $voteMapper;
70
	}
71
72
	/*
73
	 * @inheritdoc
74
	 */
75
	public function getName() {
76
		return 'Delete duplicates';
77
	}
78
79
	/**
80
	 * @inheritdoc
81
	 *
82
	 * @return void
83
	 */
84
	public function run(IOutput $output) {
85
		$this->logMapper->removeDuplicates();
86
		$this->optionMapper->removeDuplicates();
87
		$this->preferencesMapper->removeDuplicates();
88
		$this->shareMapper->removeDuplicates();
89
		$this->subscriptionMapper->removeDuplicates();
90
		$this->voteMapper->removeDuplicates();
91
	}
92
}
93