| Conditions | 8 | 
| Paths | 13 | 
| Total Lines | 56 | 
| Code Lines | 32 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 15 | ||
| Bugs | 1 | Features | 5 | 
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 | ||
| 52 | protected function execute(InputInterface $input, OutputInterface $output) | ||
| 53 |     { | ||
| 54 |         $destOption = $input->getOption('dest'); | ||
| 55 |         if ($destOption) { | ||
| 56 | $dest = realpath($destOption); | ||
| 57 |             if (false === $dest) { | ||
| 58 |                 $output->writeln(''); | ||
| 59 |                 $output->writeln(sprintf('<error>The provided destination folder \'%s\' does not exist!</error>', $destOption)); | ||
| 60 | |||
| 61 | return 0; | ||
| 62 | } | ||
| 63 |         } else { | ||
| 64 |             $dest = $this->getContainer()->get('kernel')->getRootDir(); | ||
| 65 | } | ||
| 66 | |||
| 67 | $configuration = array( | ||
| 68 |             'application_dir' => sprintf('%s/Application', $dest), | ||
| 69 | ); | ||
| 70 | |||
| 71 |         $bundleNames = $input->getArgument('bundle'); | ||
| 72 | |||
| 73 |         if (empty($bundleNames)) { | ||
| 74 |             $output->writeln(''); | ||
| 75 |             $output->writeln('<error>You must provide a bundle name!</error>'); | ||
| 76 |             $output->writeln(''); | ||
| 77 |             $output->writeln('  Bundles availables :'); | ||
| 78 | /** @var BundleInterface $bundle */ | ||
| 79 |             foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { | ||
| 80 | $bundleMetadata = new BundleMetadata($bundle, $configuration); | ||
| 81 | |||
| 82 |                 if (!$bundleMetadata->isExtendable()) { | ||
| 83 | continue; | ||
| 84 | } | ||
| 85 | |||
| 86 |                 $output->writeln(sprintf('     - %s', $bundle->getName())); | ||
| 87 | } | ||
| 88 | |||
| 89 |             $output->writeln(''); | ||
| 90 | |||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 |         foreach ($bundleNames as $bundleName) { | ||
| 95 | $processed = $this->generate($bundleName, $configuration, $output); | ||
| 96 | |||
| 97 |             if (!$processed) { | ||
| 98 |                 $output->writeln(sprintf('<error>The bundle \'%s\' does not exist or not defined in the kernel file!</error>', $bundleName)); | ||
| 99 | |||
| 100 | return -1; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 |         $output->writeln('done!'); | ||
| 105 | |||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 170 |