Completed
Pull Request — master (#347)
by Maxence
02:26
created

SyncContact::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
4
/**
5
 * Circles - Bring cloud-users closer together.
6
 *
7
 * This file is licensed under the Affero General Public License version 3 or
8
 * later. See the COPYING file.
9
 *
10
 * @author Maxence Lange <[email protected]>
11
 * @copyright 2017
12
 * @license GNU AGPL version 3 or any later version
13
 *
14
 * This program is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License as
16
 * published by the Free Software Foundation, either version 3 of the
17
 * License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU Affero General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU Affero General Public License
25
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
 *
27
 */
28
29
30
namespace OCA\Circles\Command;
31
32
use OC\Core\Command\Base;
33
use OCA\Circles\Exceptions\CommandMissingArgumentException;
34
use OCA\Circles\Exceptions\FakeException;
35
use OCA\Circles\Service\DavService;
36
use Symfony\Component\Console\Input\InputInterface;
37
use Symfony\Component\Console\Output\OutputInterface;
38
39
40
/**
41
 * Class SyncContact
42
 *
43
 * @package OCA\Circles\Command
44
 */
45
class SyncContact extends Base {
46
47
48
	/** @var DavService */
49
	private $davService;
50
51
52
	/**
53
	 * Groups constructor.
54
	 *
55
	 * @param DavService $davService
56
	 */
57
	public function __construct(DavService $davService) {
58
		parent::__construct();
59
60
		$this->davService = $davService;
61
	}
62
63
64
	protected function configure() {
65
		parent::configure();
66
		$this->setName('circles:sync')
67
			 ->setDescription('sync contacts, when using the Circles app as a backend of the Contact app');
68
	}
69
70
71
	protected function execute(InputInterface $input, OutputInterface $output) {
72
		$this->davService->migration();
73
74
		$output->writeln('migration done');
75
	}
76
77
78
	/**
79
	 * @param InputInterface $input
80
	 * @param OutputInterface $output
81
	 *
82
	 * @throws FakeException
83
	 */
84
	private function listLinkedGroups(InputInterface $input, OutputInterface $output) {
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
85
		if ($input->getOption('list') !== true) {
86
			return;
87
		}
88
89
		throw new FakeException();
90
	}
91
92
93
	/**
94
	 * @param InputInterface $input
95
	 * @param OutputInterface $output
96
	 *
97
	 * @throws FakeException
98
	 */
99 View Code Duplication
	private function addLinkedGroups(InputInterface $input, OutputInterface $output) {
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
Duplication introduced by
This method 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...
100
		if ($input->getOption('link') !== true) {
101
			return;
102
		}
103
104
		list($circleId, $group) = $this->getCircleIdAndGroupFromArguments($input);
0 ignored issues
show
Unused Code introduced by
The assignment to $circleId is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $group is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
105
106
		throw new FakeException();
107
	}
108
109
110
	/**
111
	 * @param InputInterface $input
112
	 * @param OutputInterface $output
113
	 *
114
	 * @throws FakeException
115
	 */
116 View Code Duplication
	private function delLinkedGroups(InputInterface $input, OutputInterface $output) {
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
Duplication introduced by
This method 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...
117
		if ($input->getOption('unlink') !== true) {
118
			return;
119
		}
120
121
		list($circleId, $group) = $this->getCircleIdAndGroupFromArguments($input);
0 ignored issues
show
Unused Code introduced by
The assignment to $circleId is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $group is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
122
123
		throw new FakeException();
124
	}
125
126
127 View Code Duplication
	private function getCircleIdAndGroupFromArguments(InputInterface $input) {
0 ignored issues
show
Duplication introduced by
This method 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...
128
		if ($input->getArgument('circle_id') === null
129
			|| $input->getArgument('group') === null) {
130
			throw new CommandMissingArgumentException();
131
//			$this->l10n->t(
132
//				'Missing argument: {cmd} circle_id group', ['cmd' => './occ circles:link']
133
//			)
134
		}
135
136
		return [$input->getArgument('circle_id'), $input->getArgument('group')];
137
	}
138
139
}
140
141