@@ 15-64 (lines=50) @@ | ||
12 | use Symfony\Component\Console\Output\OutputInterface; |
|
13 | use Zend\Code\Generator\FileGenerator; |
|
14 | ||
15 | class FixerCommand extends Command |
|
16 | { |
|
17 | /** |
|
18 | * @var string |
|
19 | * |
|
20 | * Command name |
|
21 | */ |
|
22 | const COMMAND_NAME = 'fix'; |
|
23 | ||
24 | /** |
|
25 | * configure |
|
26 | */ |
|
27 | protected function configure() |
|
28 | { |
|
29 | $this |
|
30 | ->setName('fix') |
|
31 | ->setDescription('Adds 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->addBackslashes($file); |
|
58 | } |
|
59 | ||
60 | $output->write('Success! Backslashes added!', true); |
|
61 | ||
62 | return $output; |
|
63 | } |
|
64 | } |
|
65 |
@@ 15-64 (lines=50) @@ | ||
12 | use Symfony\Component\Console\Output\OutputInterface; |
|
13 | use Zend\Code\Generator\FileGenerator; |
|
14 | ||
15 | class RemoverCommand extends Command |
|
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 |