|
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')), |
|
|
|
|
|
|
73
|
|
|
$this->io->getOption('project-fork'), |
|
|
|
|
|
|
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
|
|
|
|