| Conditions | 2 |
| Paths | 2 |
| Total Lines | 55 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 32 | public function load(array $config, ContainerBuilder $container) |
||
| 33 | { |
||
| 34 | $config = $this->processConfiguration(new Configuration(), $config); |
||
| 35 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
| 36 | |||
| 37 | $loader->load(sprintf('driver/%s.xml', $config['driver'])); |
||
| 38 | |||
| 39 | $this->registerResources('sylius', $config['driver'], $config['resources'], $container); |
||
| 40 | |||
| 41 | $configFiles = array( |
||
| 42 | 'services.xml', |
||
| 43 | ); |
||
| 44 | |||
| 45 | foreach ($configFiles as $configFile) { |
||
| 46 | $loader->load($configFile); |
||
| 47 | } |
||
| 48 | |||
| 49 | $factoryDefinition = new Definition(Factory::class); |
||
| 50 | $factoryDefinition->setArguments( |
||
| 51 | array( |
||
| 52 | new Parameter('sylius.model.taxonomy.class') |
||
| 53 | ) |
||
| 54 | ); |
||
| 55 | |||
| 56 | $translatableFactoryDefinition = $container->getDefinition('sylius.factory.taxonomy'); |
||
| 57 | $taxonomyFactoryClass = $translatableFactoryDefinition->getClass(); |
||
| 58 | $translatableFactoryDefinition->setClass(TranslatableFactory::class); |
||
| 59 | $translatableFactoryDefinition->setArguments( |
||
| 60 | array( |
||
| 61 | $factoryDefinition, |
||
| 62 | new Reference('sylius.translation.locale_provider') |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | |||
| 66 | $decoratedTaxonomyFactoryDefinition = new Definition($taxonomyFactoryClass); |
||
| 67 | $decoratedTaxonomyFactoryDefinition->setArguments( |
||
| 68 | array( |
||
| 69 | $translatableFactoryDefinition, |
||
| 70 | new Reference('sylius.factory.taxon') |
||
| 71 | ) |
||
| 72 | ); |
||
| 73 | |||
| 74 | $container->setDefinition('sylius.factory.taxonomy', $decoratedTaxonomyFactoryDefinition); |
||
| 75 | |||
| 76 | $taxonFactoryDefinition = $container->getDefinition('sylius.factory.taxon'); |
||
| 77 | $taxonFactoryClass = $taxonFactoryDefinition->getClass(); |
||
| 78 | $taxonFactoryDefinition->setClass(TranslatableFactory::class); |
||
| 79 | |||
| 80 | $decoratedTaxonFactoryDefinition = new Definition($taxonFactoryClass); |
||
| 81 | $decoratedTaxonFactoryDefinition |
||
| 82 | ->addArgument($taxonFactoryDefinition) |
||
| 83 | ->addArgument(new Reference('sylius.repository.taxonomy')) |
||
| 84 | ; |
||
| 85 | $container->setDefinition('sylius.factory.taxon', $decoratedTaxonFactoryDefinition); |
||
| 86 | } |
||
| 87 | } |
||
| 88 |