Completed
Pull Request — master (#379)
by Maxence
01:44
created

CirclesDestroy::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
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\CircleDoesNotExistException;
34
use OCA\Circles\Exceptions\ConfigNoCircleAvailableException;
35
use OCA\Circles\Exceptions\MemberIsNotOwnerException;
36
use OCA\Circles\Service\CirclesService;
37
use OCP\IL10N;
38
use Symfony\Component\Console\Input\InputArgument;
39
use Symfony\Component\Console\Input\InputInterface;
40
use Symfony\Component\Console\Output\OutputInterface;
41
42
43
/**
44
 * Class CirclesRemove
45
 *
46
 * @package OCA\Circles\Command
47
 */
48
class CirclesDestroy extends Base {
49
50
51
	/** @var IL10N */
52
	private $l10n;
53
54
	/** @var CirclesService */
55
	private $circlesService;
56
57
58
	/**
59
	 * CirclesRemove constructor.
60
	 *
61
	 * @param IL10N $l10n
62
	 * @param CirclesService $circlesService
63
	 */
64
	public function __construct(IL10N $l10n, CirclesService $circlesService) {
65
		parent::__construct();
66
		$this->l10n = $l10n;
67
		$this->circlesService = $circlesService;
68
	}
69
70
71
	protected function configure() {
72
		parent::configure();
73
		$this->setName('circles:manage:destroy')
74
			 ->setDescription('destroy a circle by its ID')
75
			 ->addArgument('circle_id', InputArgument::REQUIRED, 'ID of the circle to be destroyed');
76
	}
77
78
79
	/**
80
	 * @param InputInterface $input
81
	 * @param OutputInterface $output
82
	 *
83
	 * @return int
84
	 * @throws CircleDoesNotExistException
85
	 * @throws ConfigNoCircleAvailableException
86
	 * @throws MemberIsNotOwnerException
87
	 */
88
	protected function execute(InputInterface $input, OutputInterface $output): int {
89
		$circleId = $input->getArgument('circle_id');
90
91
		$this->circlesService->removeCircle($circleId, true);
92
93
		return 0;
94
	}
95
96
}
97
98