AnalyseCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 33
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 10 2
A getRefactorPriorityQuery() 0 4 1
1
<?php
2
3
namespace Hgraca\Phorensic\Analyser;
4
5
use Hgraca\Phorensic\Analyser\Query\RefactorPriorityQuery;
6
use Hgraca\Phorensic\SharedKernel\Command\StorageAwareCommandAbstract;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
final class AnalyseCommand extends StorageAwareCommandAbstract
12
{
13
    /**
14
     * {@inheritDoc}
15
     */
16
    protected function configure()
17
    {
18
        $this
19
            ->setName('phorensic:analyse')
20
            ->setDescription('Analyse the data stored in a DB.')
21
            ->addArgument('dbPath', InputArgument::REQUIRED, 'What db do you want to analyse?')
22
            ->addArgument('limit', InputArgument::OPTIONAL, 'How many results do you want to see?', null);
23
    }
24
25
    /**
26
     * {@inheritDoc}
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $refactorPriorityQuery = $this->getRefactorPriorityQuery($input);
31
32
        $data = $refactorPriorityQuery->execute($input->getArgument('limit'));
33
34
        foreach ($data as $dataRow) {
35
            $output->writeln(str_pad($dataRow['refactor_priority'], 5, ' ', STR_PAD_LEFT) . ' ' . $dataRow['path']);
36
        }
37
    }
38
39
    private function getRefactorPriorityQuery(InputInterface $input): RefactorPriorityQuery
40
    {
41
        return new RefactorPriorityQuery($this->getDatabaseClient($this->getDatabasePath($input)));
42
    }
43
}
44