| Conditions | 5 |
| Paths | 5 |
| Total Lines | 56 |
| Code Lines | 32 |
| 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 |
||
| 148 | protected function generate(string $bundleName, array $configuration, OutputInterface $output): bool |
||
| 149 | { |
||
| 150 | $processed = false; |
||
| 151 | |||
| 152 | /** @var BundleInterface $bundle */ |
||
| 153 | foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { |
||
| 154 | if ($bundle->getName() != $bundleName) { |
||
| 155 | continue; |
||
| 156 | } |
||
| 157 | |||
| 158 | $processed = true; |
||
| 159 | $bundleMetadata = new BundleMetadata($bundle, $configuration); |
||
| 160 | |||
| 161 | // generate the bundle file. |
||
| 162 | if (!$bundleMetadata->isExtendable()) { |
||
| 163 | $output->writeln(sprintf('Ignoring bundle : "<comment>%s</comment>"', $bundleMetadata->getClass())); |
||
| 164 | |||
| 165 | continue; |
||
| 166 | } |
||
| 167 | |||
| 168 | // generate the bundle file |
||
| 169 | if (!$bundleMetadata->isValid()) { |
||
| 170 | $output->writeln(sprintf( |
||
| 171 | '%s : <comment>wrong directory structure</comment>', |
||
| 172 | $bundleMetadata->getClass() |
||
| 173 | )); |
||
| 174 | |||
| 175 | continue; |
||
| 176 | } |
||
| 177 | |||
| 178 | $output->writeln(sprintf('Processing bundle : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 179 | |||
| 180 | $this->getContainer()->get('sonata.easy_extends.generator.bundle') |
||
| 181 | ->generate($output, $bundleMetadata); |
||
| 182 | |||
| 183 | $output->writeln(sprintf('Processing Doctrine ORM : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 184 | $this->getContainer()->get('sonata.easy_extends.generator.orm') |
||
| 185 | ->generate($output, $bundleMetadata); |
||
| 186 | |||
| 187 | $output->writeln(sprintf('Processing Doctrine ODM : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 188 | $this->getContainer()->get('sonata.easy_extends.generator.odm') |
||
| 189 | ->generate($output, $bundleMetadata); |
||
| 190 | |||
| 191 | $output->writeln(sprintf('Processing Doctrine PHPCR : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 192 | $this->getContainer()->get('sonata.easy_extends.generator.phpcr') |
||
| 193 | ->generate($output, $bundleMetadata); |
||
| 194 | |||
| 195 | $output->writeln(sprintf('Processing Serializer config : "<info>%s</info>"', $bundleMetadata->getName())); |
||
| 196 | $this->getContainer()->get('sonata.easy_extends.generator.serializer') |
||
| 197 | ->generate($output, $bundleMetadata); |
||
| 198 | |||
| 199 | $output->writeln(''); |
||
| 200 | } |
||
| 201 | |||
| 202 | return $processed; |
||
| 203 | } |
||
| 204 | } |
||
| 205 |