Completed
Pull Request — master (#32368)
by Matthew
12:09
created

MoveApps::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Matthew Setter <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2018, ownCloud GmbH
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 OC\Core\Command\App;
23
24
use OC\Core\Command\Base;
25
use OCP\App\IAppManager;
26
use OCP\IConfig;
27
use Symfony\Component\Console\Input\InputInterface;
28
use Symfony\Component\Console\Input\InputArgument;
29
use Symfony\Component\Console\Input\InputOption;
30
use Symfony\Component\Console\Output\OutputInterface;
31
32
class MoveApps extends Base {
33
34
	/** @var IAppManager */
35
	protected $manager;
36
37
	/** * @var IConfig */
38
	private $config;
39
40
	/**
41
	 * @param IAppManager $manager
42
	 * @param IConfig $config
43
	 */
44
	public function __construct(IAppManager $manager, IConfig $config) {
45
		parent::__construct();
46
47
		$this->manager = $manager;
48
		$this->config = $config;
49
	}
50
51
	protected function configure() {
52
		parent::configure();
53
54
		$this
55
			->setName('app:move')
56
			->setDescription('Move apps from the core apps directory to a non-core apps directory.')
57
			->addArgument(
58
				'listNonCoreDirectories',
59
				InputArgument::OPTIONAL,
60
				'List any non-core app directories'
61
			)
62
		;
63
	}
64
65
	/**
66
	 * @param InputInterface $input
67
	 * @param OutputInterface $output
68
	 * @return int|null|void
69
	 */
70
	protected function execute(InputInterface $input, OutputInterface $output) {
71
		if ($input->hasArgument('listNonCoreDirectories')) {
72
			$this->writeNonAppDirectories($input, $output);
73
		}
74
	}
75
76
	/**
77
	 * @param InputInterface $input
78
	 * @param OutputInterface $output
79
	 * @param array $items
0 ignored issues
show
Bug introduced by
There is no parameter named $items. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
80
	 */
81
	protected function writeNonAppDirectories(InputInterface $input, OutputInterface $output) {
82
		$appPaths = $this->config->getSystemValue('apps_paths');
83
		$output->writeln('Non-App Directories:');
84
		$directories = [];
85
		foreach ($appPaths as $path) {
86
			if ($path['url'] !== '/apps' && $path['writable'] === true) {
87
				$directories[] = sprintf("%s -> %s", $path['url'], $path['path']);
88
			}
89
		}
90
91
		parent::writeArrayInOutputFormat($input, $output, $directories);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (writeArrayInOutputFormat() instead of writeNonAppDirectories()). Are you sure this is correct? If so, you might want to change this to $this->writeArrayInOutputFormat().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
92
	}
93
}
94