Completed
Push — master ( d2992a...8fe16f )
by Michał
06:47
created

Commands::configure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 27
cts 27
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 25
nc 1
nop 0
crap 1
1
<?php
2
3
namespace CloverReporter\Console;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\InputArgument;
9
use CloverReporter\Parser;
10
use CloverReporter\Render;
11
12
class Commands extends Command
13
{
14 7
    protected function configure()
15
    {
16 7
        $this->setName('reporter')
17 7
            ->setDescription('Generate coverage report based on clover report file.')
18 7
            ->setHelp('');
19
20 7
        $this->addArgument(
21 7
            'report_file',
22 7
            InputArgument::OPTIONAL,
23 7
            'clover.xml report file',
24
            'build/logs/clover.xml'
25 7
        );
26
27 7
        $this->addArgument(
28 7
            'output',
29 7
            InputArgument::OPTIONAL,
30 7
            'destination of html report files',
31 7
            dirname(getcwd()) . '/output'
32 7
        );
33
34 7
        $this->addOption('open-browser', 'b', null, 'automatically open default browser with html report');
35 7
        $this->addOption('html', 'H', null, 'generate html report version');
36 7
        $this->addOption('show-coverage', 'c', null, 'show only classes with coverage in percent');
37 7
        $this->addOption('short-report', 's', null, 'show coverage in percent per line with uncovered lines only');
38 7
        $this->addOption('full-report', 'f', null, 'show coverage in percent per line with complete script');
39 7
        $this->addOption(
40 7
            'skip-dir',
41 7
            'd',
42 7
            InputArgument::OPTIONAL,
43 7
            'allow to skip specified dirs in root path. Dir delimiter: ";"',
44
            'vendor;test;tests'
45 7
        );
46 7
    }
47
48
    /**
49
     * @param InputInterface $input
50
     * @param OutputInterface $output
51
     * @return int|null|void
52
     * @throws \InvalidArgumentException
53
     */
54 7
    protected function execute(InputInterface $input, OutputInterface $output)
55
    {
56 7
        $startTime = microtime(true);
57 7
        $style = new Style($input, $output, $this);
58
59 7
        $style->title('Clover report generator.');
60
61 7
        $style->formatSection('Coverage report file', $input->getArgument('report_file'));
62 7
        $output->writeln('');
63
//        $output->writeln('output: ' . $input->getArgument('output'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
65 7
        $parser = new Parser(
66 7
            $input->getArgument('report_file'),
67 7
            $input->getOptions()
68 7
        );
69
70 6
        $infoList = $parser->getInfoList();
71
72 6
        $render = new Render($input->getOptions(), $infoList, $style);
73
74
        /** @todo in future make report generation in html */
75
//        if ($input->getOption('html')) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
76
//            $render->htmlReport();
77
//        }
78
79
//        if ($input->getOption('open-browser') && $input->getOption('html')) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
80
//            $url = $input->getArgument('output') . '/index.html';
81
//            shell_exec('x-www-browser' . $url);
82
//        }
83
84 6
        if ($input->getOption('short-report')) {
85 2
            $render->shortReport();
86 2
        }
87
88 6
        if ($input->getOption('full-report')) {
89 1
            $render->fullReport();
90 1
        }
91
92 6
        if ($input->getOption('show-coverage')) {
93 2
            $render->displayCoverage();
94 2
        }
95
96 6
        $render->summary($startTime);
97 6
    }
98
}
99