| Conditions | 5 |
| Paths | 4 |
| Total Lines | 68 |
| Code Lines | 38 |
| 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 |
||
| 47 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 48 | { |
||
| 49 | $packageName = $input->getArgument('name'); |
||
| 50 | |||
| 51 | $fromSource = $input->getOption('from-source'); |
||
| 52 | $repositoryUrl = $input->getOption('url'); |
||
| 53 | |||
| 54 | $composerRuntime = $this->getComposer(); |
||
| 55 | |||
| 56 | try { |
||
| 57 | $package = $this->resolvePackage(is_string($packageName) ? $packageName : ''); |
||
| 58 | } catch (PackageResolverException $exception) { |
||
| 59 | $this->printException($exception, $output); |
||
| 60 | |||
| 61 | return 1; |
||
| 62 | } |
||
| 63 | |||
| 64 | $confResolverFactory = new Factories\Changelog\ConfigResolverFactory($composerRuntime); |
||
| 65 | |||
| 66 | $confResolver = $confResolverFactory->create($fromSource); |
||
| 67 | |||
| 68 | $changelogLoader = new \Vaimo\ComposerChangelogs\Loaders\ChangelogLoader($confResolver); |
||
| 69 | |||
| 70 | $validator = new \Vaimo\ComposerChangelogs\Validators\ChangelogValidator($changelogLoader, array( |
||
| 71 | 'failure' => '<error>%s</error>', |
||
| 72 | 'success' => '<info>%s</info>' |
||
| 73 | )); |
||
| 74 | |||
| 75 | $result = $validator->validateForPackage($package, $output->getVerbosity()); |
||
| 76 | |||
| 77 | if (!$result()) { |
||
| 78 | array_map(array($output, 'writeln'), $result->getMessages()); |
||
| 79 | |||
| 80 | return 1; |
||
| 81 | } |
||
| 82 | |||
| 83 | $output->writeln( |
||
| 84 | sprintf('Generating changelog output for <info>%s</info>', $package->getName()) |
||
| 85 | ); |
||
| 86 | |||
| 87 | $infoResolver = new Resolvers\PackageInfoResolver( |
||
| 88 | $composerRuntime->getInstallationManager() |
||
| 89 | ); |
||
| 90 | |||
| 91 | $featureFlags = $confResolver->getFeatureFlags($package); |
||
| 92 | |||
| 93 | $urlResolver = $this->createUrlResolver($repositoryUrl, $featureFlags); |
||
| 94 | |||
| 95 | $docsGenerator = new \Vaimo\ComposerChangelogs\Generators\DocumentationGenerator( |
||
| 96 | $confResolver, |
||
| 97 | $changelogLoader, |
||
| 98 | $infoResolver, |
||
| 99 | $urlResolver |
||
| 100 | ); |
||
| 101 | |||
| 102 | try { |
||
| 103 | $docsGenerator->generate($package); |
||
| 104 | } catch (\Vaimo\ComposerChangelogs\Exceptions\GeneratorException $exception) { |
||
| 105 | $output->writeln( |
||
| 106 | sprintf('<error>%s</error>', $exception->getMessage()) |
||
| 107 | ); |
||
| 108 | |||
| 109 | return 1; |
||
| 110 | } |
||
| 111 | |||
| 112 | $output->writeln('<info>Done</info>'); |
||
| 113 | |||
| 114 | return 0; |
||
| 115 | } |
||
| 162 |