| Conditions | 4 |
| Paths | 4 |
| Total Lines | 51 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 41 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 42 | { |
||
| 43 | $packageName = $input->getArgument('name'); |
||
| 44 | $type = $input->getOption('type'); |
||
| 45 | |||
| 46 | $composerCtxFactory = new \Vaimo\ComposerChangelogs\Factories\ComposerContextFactory($this->getComposer()); |
||
| 47 | $composerCtx = $composerCtxFactory->create(); |
||
| 48 | |||
| 49 | $commandCtx = new \Vaimo\ComposerChangelogs\Console\Command\ExecutionContext($output, $composerCtx); |
||
| 50 | |||
| 51 | $cfgResolverFactory = new \Vaimo\ComposerChangelogs\Factories\Changelog\ConfigResolverFactory($composerCtx); |
||
| 52 | $cfgResolver = $cfgResolverFactory->create(); |
||
| 53 | |||
| 54 | $packageManager = new \Vaimo\ComposerChangelogs\Managers\PackageManager($composerCtx); |
||
| 55 | |||
| 56 | $package = $commandCtx->resolvePackage($packageName); |
||
| 57 | |||
| 58 | if ($package === null) { |
||
| 59 | return 1; |
||
| 60 | } |
||
| 61 | |||
| 62 | $output->writeln( |
||
| 63 | sprintf('Bootstrapping changelog generation for <info>%s</info>', $package->getName()) |
||
| 64 | ); |
||
| 65 | |||
| 66 | if ($cfgResolver->hasConfig($package)) { |
||
| 67 | $rootPath = array(ComposerConfig::CONFIG_ROOT, PluginConfig::ROOT); |
||
| 68 | |||
| 69 | $message = sprintf( |
||
| 70 | 'Configuration root (<comment>%s</comment>) already present in package config', |
||
| 71 | implode('/', $rootPath) |
||
| 72 | ); |
||
| 73 | |||
| 74 | $output->writeln($message); |
||
| 75 | |||
| 76 | return 0; |
||
| 77 | } |
||
| 78 | |||
| 79 | try { |
||
| 80 | $packageManager->bootstrapChangelogGeneration($package, $type); |
||
| 81 | } catch (\Vaimo\ComposerChangelogs\Exceptions\UpdaterException $exception) { |
||
| 82 | $message = sprintf('<error>%s</error>', $exception->getMessage()); |
||
| 83 | |||
| 84 | $output->writeln($message); |
||
| 85 | |||
| 86 | return 1; |
||
| 87 | } |
||
| 88 | |||
| 89 | $output->writeln('<info>Done</info>'); |
||
| 90 | |||
| 91 | return 0; |
||
| 92 | } |
||
| 94 |