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