AnalyzeCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 37
ccs 15
cts 15
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 17 3
1
<?php
2
3
namespace PhpNsFixer\Console;
4
5
use Symfony\Component\Console\Input\ArrayInput;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
final class AnalyzeCommand extends Command
12
{
13
    /**
14
     * Configures the current command.
15
     *
16
     * @return void
17
     */
18 2
    protected function configure()
19
    {
20 2
        $this->setName('analyze')->setDescription('Analyzes a directory');
21 2
        $this->setDefinition([
22 2
            new InputArgument('path', InputArgument::REQUIRED, 'The path.'),
23 2
            new InputOption('prefix', 'P', InputOption::VALUE_REQUIRED, 'Namespace prefix.'),
24 2
            new InputOption('skip-empty', 'E', InputOption::VALUE_NONE, 'Skip files without namespace.'),
25
        ]);
26 2
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $arguments = [
34 2
            'command'   => 'fix',
35 2
            'path'      => $input->getArgument('path'),
36
            '--dry-run' => true,
37
        ];
38
39 2
        if ($input->hasOption('prefix')) {
40 2
            $arguments['--prefix'] = $input->getOption('prefix');
41
        }
42
43 2
        if ($input->hasOption('skip-empty')) {
44 2
            $arguments['--skip-empty'] = '';
45
        }
46
47 2
        return $this->getApplication()->find('fix')->run(new ArrayInput($arguments), $output);
48
    }
49
}
50