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

CirclesDetails::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
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\Db\CirclesRequest;
34
use OCA\Circles\Exceptions\CircleDoesNotExistException;
35
use OCP\IL10N;
36
use Symfony\Component\Console\Input\InputArgument;
37
use Symfony\Component\Console\Input\InputInterface;
38
use Symfony\Component\Console\Output\OutputInterface;
39
40
41
/**
42
 * Class CirclesDetails
43
 *
44
 * @package OCA\Circles\Command
45
 */
46 View Code Duplication
class CirclesDetails extends Base {
0 ignored issues
show
Duplication introduced by
This class 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...
47
48
49
	/** @var IL10N */
50
	private $l10n;
51
52
	/** @var CirclesRequest */
53
	private $circlesRequest;
54
55
56
	/**
57
	 * CirclesDetails constructor.
58
	 *
59
	 * @param IL10N $l10n
60
	 * @param CirclesRequest $circlesRequest
61
	 */
62
	public function __construct(IL10N $l10n, CirclesRequest $circlesRequest) {
63
		parent::__construct();
64
		$this->l10n = $l10n;
65
		$this->circlesRequest = $circlesRequest;
66
	}
67
68
69
	protected function configure() {
70
		parent::configure();
71
		$this->setName('circles:manage:details')
72
			 ->setDescription('get details about a circle by its ID')
73
			 ->addArgument('circle_id', InputArgument::REQUIRED, 'ID of the circle');
74
	}
75
76
77
	/**
78
	 * @param InputInterface $input
79
	 * @param OutputInterface $output
80
	 *
81
	 * @return int
82
	 * @throws CircleDoesNotExistException
83
	 */
84
	protected function execute(InputInterface $input, OutputInterface $output): int {
85
		$circleId = $input->getArgument('circle_id');
86
87
		$circle = $this->circlesRequest->forceGetCircle($circleId);
88
89
		echo json_encode($circle, JSON_PRETTY_PRINT) . "\n";
90
91
		return 0;
92
	}
93
94
}
95
96