MaintenanceModeCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 4
dl 0
loc 47
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 12 1
A execute() 0 11 3
1
<?php
2
/**
3
 * @author Victor Dubiniuk <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2015, ownCloud, Inc.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace Owncloud\Updater\Command;
23
24
use Symfony\Component\Console\Input\InputInterface;
25
use Symfony\Component\Console\Input\InputOption;
26
use Symfony\Component\Console\Output\OutputInterface;
27
use Owncloud\Updater\Utils\OccRunner;
28
29
/**
30
 * Class MaintenanceModeCommand
31
 *
32
 * @package Owncloud\Updater\Command
33
 */
34
class MaintenanceModeCommand extends Command {
35
36
	/**
37
	 * @var OccRunner $occRunner
38
	 */
39
	protected $occRunner;
40
41
	/**
42
	 * Constructor
43
	 *
44
	 * @param OccRunner $occRunner
45
	 */
46
	public function __construct(OccRunner $occRunner){
47
		parent::__construct();
48
		$this->occRunner = $occRunner;
49
	}
50
51
	protected function configure(){
52
		$this
53
				->setName('upgrade:maintenanceMode')
54
				->setDescription('Toggle maintenance mode')
55
				->addOption(
56
						'on', null, InputOption::VALUE_NONE, 'enable maintenance mode'
57
				)
58
				->addOption(
59
						'off', null, InputOption::VALUE_NONE, 'disable maintenance mode'
60
				)
61
		;
62
	}
63
64
	/**
65
	 * @param InputInterface $input
66
	 * @param OutputInterface $output
67
	 */
68
	protected function execute(InputInterface $input, OutputInterface $output){
69
		$args = [];
70
		if ($input->getOption('on')){
71
			$args = ['--on' => ''];
72
		} elseif ($input->getOption('off')){
73
			$args = ['--off' => ''];
74
		}
75
76
		$response = $this->occRunner->run('maintenance:mode', $args);
77
		$output->writeln($response);
78
	}
79
80
}
81