| Conditions | 4 |
| Paths | 8 |
| Total Lines | 62 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 103 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 104 | { |
||
| 105 | // Finalize the container |
||
| 106 | $this->finalizeContainer($input); |
||
| 107 | |||
| 108 | // Change runtime memory |
||
| 109 | if($memory = $input->getOption('memory_limit')) { |
||
| 110 | ini_set("memory_limit", $memory); |
||
| 111 | } |
||
| 112 | // Input/output dirs |
||
| 113 | $inputDirectory = $input->getArgument('input_directory'); |
||
| 114 | $outputDirectory = $input->getArgument('output_directory'); |
||
| 115 | |||
| 116 | if (!empty($outputDirectory)) { |
||
| 117 | |||
| 118 | $output->writeln(sprintf( |
||
| 119 | 'Copying input directory <info>%s</info> to <info>%s</info>', |
||
| 120 | $inputDirectory, |
||
| 121 | $outputDirectory |
||
| 122 | )); |
||
| 123 | |||
| 124 | $this->copyDir($inputDirectory, $outputDirectory); |
||
| 125 | |||
| 126 | $directory = $outputDirectory; |
||
| 127 | } else { |
||
| 128 | $directory = $inputDirectory; |
||
| 129 | } |
||
| 130 | |||
| 131 | // Strip whitespace? |
||
| 132 | $stripWhitespace = !$input->getOption('leave_whitespace'); |
||
| 133 | $ignoreError = !!$input->getOption('ignore_error'); |
||
| 134 | |||
| 135 | // Show every file |
||
| 136 | $this->getObfuscator()->getEventDispatcher()->addListener( |
||
| 137 | 'obfuscator.file', |
||
| 138 | function(FileEvent $event) use ($output, $directory) { |
||
| 139 | $output->writeln(sprintf( |
||
| 140 | 'Obfuscating <info>%s</info>', |
||
| 141 | substr($event->getFile(), strlen($directory)) |
||
| 142 | )); |
||
| 143 | } |
||
| 144 | ); |
||
| 145 | // Show error processing file |
||
| 146 | if($ignoreError) { |
||
| 147 | $this->getObfuscator()->getEventDispatcher()->addListener( |
||
| 148 | 'obfuscator.file.error', |
||
| 149 | function(FileErrorEvent $event) use ($output, $directory) { |
||
| 150 | $output->writeln(sprintf( |
||
| 151 | 'Error obfuscating <error>%s</error>', |
||
| 152 | substr($event->getFile(), strlen($directory)) |
||
| 153 | )); |
||
| 154 | $output->writeln(sprintf( |
||
| 155 | 'Parsing error: <error>%s</error>', $event->getErrorMessage() |
||
| 156 | )); |
||
| 157 | } |
||
| 158 | ); |
||
| 159 | } |
||
| 160 | |||
| 161 | // Actual obfuscation |
||
| 162 | $this->getObfuscator()->obfuscate($directory, $stripWhitespace, |
||
| 163 | $ignoreError); |
||
| 164 | } |
||
| 165 | |||
| 255 |