EnableBackend   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
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 35
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 EnableBackend extends Command {
14
15
	/**
16
	 * @var \OCA\Chat\IBackendManager
17
	 */
18
	private $backendManager;
19
20
21
	public function __construct(IBackendManager $backendManager){
22
		$this->backendManager = $backendManager;
23
		parent::__construct();
24
	}
25
	
26
	public function configure(){
27
		$this->setName('chat-backend:enable')
28
			->setDescription('Enable a specific backend')
29
			->addArgument(
30
				'backend',
31
				InputArgument::REQUIRED,
32
				'The id of the backend which you want to enable'
33
				)
34
			;
35
	}
36
37
	public function execute(InputInterface $input, OutputInterface $output){
38
		$backend = $input->getArgument('backend');
39
		try {
40
			$this->backendManager->enableBackend($backend);
41
			$output->writeln("Chat Backend '". $backend . "' is enabled.");
42
		} Catch (BackendNotFoundException $e) {
43
			$output->writeln("<error>Chat Backend does not exists.</error>");
44
		}
45
	}
46
	
47
}