DisableBackend   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 10 1
A execute() 0 9 2
1
<?php
2
3
namespace OCA\Chat\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use OCA\Chat\BackendNotFoundException;
10
use \OCA\CHat\IBackendManager;
11
12
13
class DisableBackend extends Command {
14
15
	/**
16
	 * @var \OCA\Chat\IBackendManager
17
	 */
18
	private $backendManager;
19
20
	public function __construct(IBackendManager $backendManager){
21
		$this->backendManager = $backendManager;
22
		parent::__construct();
23
	}
24
	
25
	public function configure(){
26
		$this->setName('chat-backend:disable')
27
			->setDescription('Disable a specific backend')
28
			->addArgument(
29
				'backend',
30
				InputArgument::REQUIRED,
31
				'The id of the backend which you want to disable'
32
				)
33
			;
34
	}
35
36
	public function execute(InputInterface $input, OutputInterface $output){
37
		$backend = $input->getArgument('backend');
38
		try {
39
			$this->backendManager->disableBackend($backend);
40
			$output->writeln("Chat Backend '". $backend . "' is disabled.");
41
		} Catch (BackendNotFoundException $e){
42
			$output->writeln("<error>Chat Backend does not exists.</error>");
43
		}
44
	}
45
	
46
}