RemoverCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %
Metric Value
dl 11
loc 11
rs 9.4286
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace NilPortugues\BackslashFixer\Command;
4
5
use Exception;
6
use NilPortugues\BackslashFixer\Fixer\FileEditor;
7
use NilPortugues\BackslashFixer\Fixer\FileSystem;
8
use NilPortugues\BackslashFixer\Fixer\FunctionRepository;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Zend\Code\Generator\FileGenerator;
14
15 View Code Duplication
class RemoverCommand extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @var string
19
     *
20
     * Command name
21
     */
22
    const COMMAND_NAME = 'undo';
23
24
    /**
25
     * configure
26
     */
27
    protected function configure()
28
    {
29
        $this
30
            ->setName('undo')
31
            ->setDescription('Removes backslashes to all internal PHP functions')
32
            ->addArgument(
33
                'path',
34
                InputArgument::REQUIRED,
35
                'Path'
36
            );
37
    }
38
39
    /**
40
     * Execute command
41
     *
42
     * @param InputInterface  $input  Input
43
     * @param OutputInterface $output Output
44
     *
45
     * @return \int|\\null|void
46
     *
47
     * @throws Exception
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51
        $path = $input->getArgument('path');
52
53
        $fileSystem = new FileSystem();
54
        $fileEditor = new FileEditor(new FileGenerator(), new FunctionRepository(), $fileSystem);
55
56
        foreach ($fileSystem->getFilesFromPath($path) as $file) {
57
            $fileEditor->removeBackslashes($file);
58
        }
59
60
        $output->write('Success! Backslashes removed!', true);
61
62
        return $output;
63
    }
64
}
65