ReportCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 25
c 2
b 0
f 0
dl 0
loc 61
ccs 0
cts 34
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareDependencies() 0 7 1
A execute() 0 12 2
A configure() 0 16 1
1
<?php
2
/**
3
 * This file is part of the Code-Insight library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/console-helpers/code-insight
9
 */
10
11
namespace ConsoleHelpers\CodeInsight\Command;
12
13
14
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class ReportCommand extends AbstractCommand
21
{
22
23
	/**
24
	 * Knowledge base factory.
25
	 *
26
	 * @var KnowledgeBaseFactory
27
	 */
28
	private $_knowledgeBaseFactory;
29
30
	/**
31
	 * {@inheritdoc}
32
	 */
33
	protected function configure()
34
	{
35
		$this
36
			->setName('report')
37
			->setDescription('Analyzes project and shows the report')
38
			->addArgument(
39
				'project-path',
40
				InputArgument::OPTIONAL,
41
				'Path to project root folder (where <comment>.code-insight.json</comment> is located)',
42
				'.'
43
			)
44
			->addOption(
45
				'project-fork',
46
				null,
47
				InputOption::VALUE_REQUIRED,
48
				'Project fork name'
49
			);
50
	}
51
52
	/**
53
	 * Prepare dependencies.
54
	 *
55
	 * @return void
56
	 */
57
	protected function prepareDependencies()
58
	{
59
		parent::prepareDependencies();
60
61
		$container = $this->getContainer();
62
63
		$this->_knowledgeBaseFactory = $container['knowledge_base_factory'];
64
	}
65
66
	/**
67
	 * {@inheritdoc}
68
	 */
69
	protected function execute(InputInterface $input, OutputInterface $output)
70
	{
71
		$knowledge_base = $this->_knowledgeBaseFactory->getKnowledgeBase(
72
			$this->getPath($this->io->getArgument('project-path')),
0 ignored issues
show
Bug introduced by
It seems like $this->io->getArgument('project-path') can also be of type string[]; however, parameter $raw_path of ConsoleHelpers\CodeInsig...tractCommand::getPath() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
			$this->getPath(/** @scrutinizer ignore-type */ $this->io->getArgument('project-path')),
Loading history...
73
			$this->io->getOption('project-fork'),
0 ignored issues
show
Bug introduced by
It seems like $this->io->getOption('project-fork') can also be of type string[]; however, parameter $fork of ConsoleHelpers\CodeInsig...ory::getKnowledgeBase() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

73
			/** @scrutinizer ignore-type */ $this->io->getOption('project-fork'),
Loading history...
74
			$this->io
75
		);
76
77
		$this->io->writeln('<comment>Report:</comment>');
78
79
		foreach ( $knowledge_base->getStatistics() as $name => $value ) {
80
			$this->io->writeln(' * ' . $name . ': <info>' . $value . '</info>');
81
		}
82
	}
83
84
}
85