| Conditions | 8 |
| Paths | 48 |
| Total Lines | 75 |
| 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 |
||
| 34 | public function load(array $configs, ContainerBuilder $container) |
||
| 35 | { |
||
| 36 | $processor = new Processor(); |
||
| 37 | $configuration = new Configuration(); |
||
| 38 | $config = $processor->processConfiguration($configuration, $configs); |
||
| 39 | $bundles = $container->getParameter('kernel.bundles'); |
||
| 40 | |||
| 41 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
| 42 | $loader->load('actions.xml'); |
||
| 43 | $loader->load('twig.xml'); |
||
| 44 | $loader->load('form.xml'); |
||
| 45 | $loader->load('core.xml'); |
||
| 46 | $loader->load('serializer.xml'); |
||
| 47 | $loader->load('command.xml'); |
||
| 48 | |||
| 49 | if (isset($bundles['SonataBlockBundle'])) { |
||
| 50 | $loader->load('block.xml'); |
||
| 51 | } |
||
| 52 | |||
| 53 | if (isset($bundles['FOSRestBundle'], $bundles['NelmioApiDocBundle'])) { |
||
| 54 | $loader->load(sprintf('api_form_%s.xml', $config['db_driver'])); |
||
| 55 | if ('doctrine_orm' === $config['db_driver']) { |
||
| 56 | $loader->load('api_controllers.xml'); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | $loader->load(sprintf('%s.xml', $config['db_driver'])); |
||
| 61 | |||
| 62 | if (isset($bundles['SonataAdminBundle'])) { |
||
| 63 | $loader->load(sprintf('%s_admin.xml', $config['db_driver'])); |
||
| 64 | } |
||
| 65 | |||
| 66 | if (!isset($config['salt'])) { |
||
| 67 | throw new \InvalidArgumentException( |
||
| 68 | 'The configuration node "salt" is not set for the SonataNewsBundle (sonata_news)' |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | |||
| 72 | if (!isset($config['comment'])) { |
||
| 73 | throw new \InvalidArgumentException( |
||
| 74 | 'The configuration node "comment" is not set for the SonataNewsBundle (sonata_news)' |
||
| 75 | ); |
||
| 76 | } |
||
| 77 | |||
| 78 | $container->getDefinition('sonata.news.hash.generator') |
||
| 79 | ->replaceArgument(0, $config['salt']); |
||
| 80 | |||
| 81 | $container->getDefinition('sonata.news.permalink.date') |
||
| 82 | ->replaceArgument(0, $config['permalink']['date']); |
||
| 83 | |||
| 84 | $container->setAlias('sonata.news.permalink.generator', $config['permalink_generator']); |
||
| 85 | |||
| 86 | $container->setDefinition('sonata.news.blog', new Definition('Sonata\NewsBundle\Model\Blog', [ |
||
| 87 | $config['title'], |
||
| 88 | $config['link'], |
||
| 89 | $config['description'], |
||
| 90 | new Reference('sonata.news.permalink.generator'), |
||
| 91 | ])); |
||
| 92 | |||
| 93 | $container->getDefinition('sonata.news.hash.generator') |
||
| 94 | ->replaceArgument(0, $config['salt']); |
||
| 95 | |||
| 96 | $container->getDefinition('sonata.news.mailer') |
||
| 97 | ->replaceArgument(5, [ |
||
| 98 | 'notification' => $config['comment']['notification'], |
||
| 99 | ]); |
||
| 100 | |||
| 101 | if ('doctrine_orm' === $config['db_driver']) { |
||
| 102 | $this->registerDoctrineMapping($config); |
||
| 103 | } |
||
| 104 | |||
| 105 | $this->configureClass($config, $container); |
||
| 106 | $this->configureAdmin($config, $container); |
||
| 107 | $this->configureStringExtension($container); |
||
| 108 | } |
||
| 109 | |||
| 277 |
If you suppress an error, we recommend checking for the error condition explicitly: