| Conditions | 11 |
| Paths | 77 |
| Total Lines | 49 |
| Code Lines | 31 |
| 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 |
||
| 26 | protected function writeToOutput(InputInterface $input, OutputInterface $output, $classMaps) |
||
| 27 | { |
||
| 28 | $baseMap = <<<PHP |
||
| 29 | <?php |
||
| 30 | namespace PHPSTORM_META { |
||
| 31 | /** @noinspection PhpUnusedLocalVariableInspection */ |
||
| 32 | /** @noinspection PhpIllegalArrayKeyTypeInspection */ |
||
| 33 | /** @noinspection PhpLanguageLevelInspection */ |
||
| 34 | \$STATIC_METHOD_TYPES = [ |
||
| 35 | PHP; |
||
| 36 | $baseMap .= "\n"; |
||
| 37 | foreach ($this->groupFactories as $group => $methods) { |
||
| 38 | $map = $baseMap; |
||
| 39 | foreach ($methods as $method) { |
||
| 40 | $map .= " " . $method . "('') => [\n"; |
||
| 41 | foreach ($classMaps[$group] as $classPrefix => $class) { |
||
| 42 | if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { |
||
| 43 | $map .= " '$classPrefix' instanceof \\$class,\n"; |
||
| 44 | } else { |
||
| 45 | $output->writeln('<warning>Invalid class name <comment>'.$class.'</comment> ignored</warning>'); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | $map .= " ], \n"; |
||
| 49 | } |
||
| 50 | $map .= <<<PHP |
||
| 51 | ]; |
||
| 52 | } |
||
| 53 | PHP; |
||
| 54 | if ($input->getOption('stdout')) { |
||
| 55 | $output->writeln($map); |
||
| 56 | } else { |
||
| 57 | $metaPath = $this->_magentoRootFolder . '/.phpstorm.meta.php'; |
||
| 58 | if (is_file($metaPath)) { |
||
| 59 | if (\unlink($metaPath)) { |
||
| 60 | $output->writeln('<info>Deprecated file <comment>.phpstorm.meta.php</comment> removed</info>'); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | if (!is_dir($metaPath)) { |
||
| 64 | if (\mkdir($metaPath)) { |
||
| 65 | $output->writeln('<info>Directory <comment>.phpstorm.meta.php</comment> created</info>'); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | $group = str_replace(array(' ', '/'), '_', $group); |
||
| 69 | if (\file_put_contents($this->_magentoRootFolder . '/.phpstorm.meta.php/magento_'.$group.'.meta.php', $map)) { |
||
| 70 | $output->writeln('<info>File <comment>.phpstorm.meta.php/magento_'.$group.'.meta.php</comment> generated</info>'); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.