Completed
Push — master ( 10f95b...bf15d4 )
by Michael
09:02
created

HelpCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 8
dl 0
loc 70
ccs 0
cts 21
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B execute() 0 36 3
A getDescription() 0 4 1
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Commands;
10
11
use Joomla\Application\Cli\ColorStyle;
12
use Joomla\Application\Cli\Output\Processor\ColorProcessor;
13
use Joomla\Controller\AbstractController;
14
use Joomla\StatsServer\CommandInterface;
15
16
/**
17
 * Help command
18
 *
19
 * @method         \Joomla\StatsServer\CliApplication  getApplication()  Get the application object.
20
 * @property-read  \Joomla\StatsServer\CliApplication  $app              Application object
21
 *
22
 * @since          1.0
23
 */
24
class HelpCommand extends AbstractController implements CommandInterface
25
{
26
	/**
27
	 * Execute the controller.
28
	 *
29
	 * @return  boolean
30
	 *
31
	 * @since   1.0
32
	 */
33
	public function execute()
34
	{
35
		/** @var ColorProcessor $processor */
36
		$processor = $this->getApplication()->getOutput()->getProcessor();
37
		$processor->addStyle('cmd', new ColorStyle('magenta'));
38
39
		$executable = basename($this->getApplication()->input->executable);
40
41
		$commands = $this->getApplication()->getConsole()->getCommands();
0 ignored issues
show
Unused Code introduced by
$commands is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
42
43
		$this->getApplication()->outputTitle($this->getTitle());
44
45
		$this->getApplication()->out(
46
			sprintf('Usage: <info>%s</info> <cmd><command></cmd>',
47
				$executable
48
			)
49
		);
50
51
		$this->getApplication()->out()
52
			->out('Available commands:')
53
			->out();
54
55
		foreach ($this->getApplication()->getConsole()->getCommands() as $cName => $command)
56
		{
57
			$this->getApplication()->out('<cmd>' . $cName . '</cmd>');
58
59
			if ($command->getDescription())
60
			{
61
				$this->getApplication()->out('    ' . $command->getDescription());
62
			}
63
64
			$this->getApplication()->out();
65
		}
66
67
		return true;
68
	}
69
70
	/**
71
	 * Get the command's description
72
	 *
73
	 * @return  string
74
	 *
75
	 * @since   1.0
76
	 */
77
	public function getDescription() : string
78
	{
79
		return 'Provides basic use information for the stats application.';
80
	}
81
82
	/**
83
	 * Get the command's title
84
	 *
85
	 * @return  string
86
	 *
87
	 * @since   1.0
88
	 */
89
	public function getTitle() : string
90
	{
91
		return 'Joomla Stats Application';
92
	}
93
}
94