| 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 |
||
| 132 | protected function generate($bundleName, array $configuration, $output) |
||
| 133 | { |
||
| 134 | $processed = false; |
||
| 135 | |||
| 136 | /** @var BundleInterface $bundle */ |
||
| 137 | foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { |
||
| 138 | if ($bundle->getName() != $bundleName) { |
||
| 139 | continue; |
||
| 140 | } |
||
| 141 | |||
| 142 | $processed = true; |
||
| 143 | $bundleMetadata = new BundleMetadata($bundle, $configuration); |
||
| 144 | |||
| 145 | // generate the bundle file |
||
| 146 | if (!$bundleMetadata->isExtendable()) { |
||
| 147 | $output->writeln(sprintf('Ignoring bundle : "<comment>%s</comment>"', $bundleMetadata->getClass())); |
||
| 148 | continue; |
||
| 149 | } |
||
| 150 | |||
| 151 | // generate the bundle file |
||
| 152 | if (!$bundleMetadata->isValid()) { |
||
| 153 | $output->writeln(sprintf('%s : <comment>wrong folder structure</comment>', $bundleMetadata->getClass())); |
||
| 154 | continue; |
||
| 155 | } |
||
| 156 | |||
| 157 | $output->writeln(sprintf('Processing bundle : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 158 | |||
| 159 | $this->getContainer()->get('sonata.easy_extends.generator.bundle') |
||
| 160 | ->generate($output, $bundleMetadata); |
||
| 161 | |||
| 162 | $output->writeln(sprintf('Processing Doctrine ORM : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 163 | $this->getContainer()->get('sonata.easy_extends.generator.orm') |
||
| 164 | ->generate($output, $bundleMetadata); |
||
| 165 | |||
| 166 | $output->writeln(sprintf('Processing Doctrine ODM : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 167 | $this->getContainer()->get('sonata.easy_extends.generator.odm') |
||
| 168 | ->generate($output, $bundleMetadata); |
||
| 169 | |||
| 170 | $output->writeln(sprintf('Processing Doctrine PHPCR : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 171 | $this->getContainer()->get('sonata.easy_extends.generator.phpcr') |
||
| 172 | ->generate($output, $bundleMetadata); |
||
| 173 | |||
| 174 | $output->writeln(sprintf('Processing Serializer config : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 175 | $this->getContainer()->get('sonata.easy_extends.generator.serializer') |
||
| 176 | ->generate($output, $bundleMetadata); |
||
| 177 | |||
| 178 | $output->writeln(''); |
||
| 179 | } |
||
| 180 | |||
| 181 | return $processed; |
||
| 182 | } |
||
| 183 | } |
||
| 184 |