| Conditions | 3 |
| Paths | 4 |
| Total Lines | 58 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 96 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 97 | { |
||
| 98 | // Finalize the container |
||
| 99 | $this->finalizeContainer($input); |
||
| 100 | |||
| 101 | // Input/output dirs |
||
| 102 | $inputDirectory = $input->getArgument('input_directory'); |
||
| 103 | $outputDirectory = $input->getArgument('output_directory'); |
||
| 104 | |||
| 105 | if (!empty($outputDirectory)) { |
||
| 106 | |||
| 107 | $output->writeln(sprintf( |
||
| 108 | 'Copying input directory <info>%s</info> to <info>%s</info>', |
||
| 109 | $inputDirectory, |
||
| 110 | $outputDirectory |
||
| 111 | )); |
||
| 112 | |||
| 113 | $this->copyDir($inputDirectory, $outputDirectory); |
||
| 114 | |||
| 115 | $directory = $outputDirectory; |
||
| 116 | } else { |
||
| 117 | $directory = $inputDirectory; |
||
| 118 | } |
||
| 119 | |||
| 120 | // Strip whitespace? |
||
| 121 | $stripWhitespace = !$input->getOption('leave_whitespace'); |
||
| 122 | $ignoreError = !!$input->getOption('ignore_error'); |
||
| 123 | |||
| 124 | // Show every file |
||
| 125 | $this->getObfuscator()->getEventDispatcher()->addListener( |
||
| 126 | 'obfuscator.file', |
||
| 127 | function(FileEvent $event) use ($output, $directory) { |
||
| 128 | $output->writeln(sprintf( |
||
| 129 | 'Obfuscating <info>%s</info>', |
||
| 130 | substr($event->getFile(), strlen($directory)) |
||
| 131 | )); |
||
| 132 | } |
||
| 133 | ); |
||
| 134 | // Show error processing file |
||
| 135 | if($ignoreError) { |
||
| 136 | $this->getObfuscator()->getEventDispatcher()->addListener( |
||
| 137 | 'obfuscator.file.error', |
||
| 138 | function(FileErrorEvent $event) use ($output, $directory) { |
||
| 139 | $output->writeln(sprintf( |
||
| 140 | 'Error obfuscating <error>%s</error>', |
||
| 141 | substr($event->getFile(), strlen($directory)) |
||
| 142 | )); |
||
| 143 | $output->writeln(sprintf( |
||
| 144 | 'Parsing error: <error>%s</error>', $event->getErrorMessage() |
||
| 145 | )); |
||
| 146 | } |
||
| 147 | ); |
||
| 148 | } |
||
| 149 | |||
| 150 | // Actual obfuscation |
||
| 151 | $this->getObfuscator()->obfuscate($directory, $stripWhitespace, |
||
| 152 | $ignoreError); |
||
| 153 | } |
||
| 154 | |||
| 237 |