| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 51 | 
| Code Lines | 30 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 1 | Features | 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 | ||
| 118 | protected function generate($bundleName, array $configuration, $output) | ||
| 119 |     { | ||
| 120 | $processed = false; | ||
| 121 | |||
| 122 | /** @var BundleInterface $bundle */ | ||
| 123 |         foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { | ||
| 124 |             if ($bundle->getName() != $bundleName) { | ||
| 125 | continue; | ||
| 126 | } | ||
| 127 | |||
| 128 | $processed = true; | ||
| 129 | $bundleMetadata = new BundleMetadata($bundle, $configuration); | ||
| 130 | |||
| 131 | // generate the bundle file | ||
| 132 |             if (!$bundleMetadata->isExtendable()) { | ||
| 133 |                 $output->writeln(sprintf('Ignoring bundle : "<comment>%s</comment>"', $bundleMetadata->getClass())); | ||
| 134 | continue; | ||
| 135 | } | ||
| 136 | |||
| 137 | // generate the bundle file | ||
| 138 |             if (!$bundleMetadata->isValid()) { | ||
| 139 |                 $output->writeln(sprintf('%s : <comment>wrong folder structure</comment>', $bundleMetadata->getClass())); | ||
| 140 | continue; | ||
| 141 | } | ||
| 142 | |||
| 143 |             $output->writeln(sprintf('Processing bundle : "<info>%s</info>"', $bundleMetadata->getName())); | ||
| 144 | |||
| 145 |             $this->getContainer()->get('sonata.easy_extends.generator.bundle') | ||
| 146 | ->generate($output, $bundleMetadata); | ||
| 147 | |||
| 148 |             $output->writeln(sprintf('Processing Doctrine ORM : "<info>%s</info>"', $bundleMetadata->getName())); | ||
| 149 |             $this->getContainer()->get('sonata.easy_extends.generator.orm') | ||
| 150 | ->generate($output, $bundleMetadata); | ||
| 151 | |||
| 152 |             $output->writeln(sprintf('Processing Doctrine ODM : "<info>%s</info>"', $bundleMetadata->getName())); | ||
| 153 |             $this->getContainer()->get('sonata.easy_extends.generator.odm') | ||
| 154 | ->generate($output, $bundleMetadata); | ||
| 155 | |||
| 156 |             $output->writeln(sprintf('Processing Doctrine PHPCR : "<info>%s</info>"', $bundleMetadata->getName())); | ||
| 157 |             $this->getContainer()->get('sonata.easy_extends.generator.phpcr') | ||
| 158 | ->generate($output, $bundleMetadata); | ||
| 159 | |||
| 160 |             $output->writeln(sprintf('Processing Serializer config : "<info>%s</info>"', $bundleMetadata->getName())); | ||
| 161 |             $this->getContainer()->get('sonata.easy_extends.generator.serializer') | ||
| 162 | ->generate($output, $bundleMetadata); | ||
| 163 | |||
| 164 |             $output->writeln(''); | ||
| 165 | } | ||
| 166 | |||
| 167 | return $processed; | ||
| 168 | } | ||
| 169 | } | ||
| 170 |