Conditions | 10 |
Paths | 16 |
Total Lines | 37 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
55 | public function handleConfiguration(array $config, ContainerBuilder $container): void |
||
56 | { |
||
57 | if (!isset($config['export']) || !isset($config['export']['enabled']) || false == $config['export']['enabled']) { |
||
58 | return; |
||
59 | } |
||
60 | |||
61 | $container->setParameter('parthenon_export_enabled', true); |
||
62 | |||
63 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config')); |
||
64 | $loader->load('services/export.xml'); |
||
65 | |||
66 | $container->registerForAutoconfiguration(NormaliserInterface::class)->addTag('parthenon.export.normaliser'); |
||
67 | $container->registerForAutoconfiguration(ExporterInterface::class)->addTag('parthenon.export.exporter'); |
||
68 | $container->registerForAutoconfiguration(DataProviderInterface::class)->addTag('parthenon.export.data_provider'); |
||
69 | |||
70 | $bundles = $container->getParameter('kernel.bundles'); |
||
71 | |||
72 | $this->configureMongoDb($bundles, $loader); |
||
73 | $this->configureDoctrine($bundles, $loader); |
||
74 | |||
75 | if (isset($config['export']['default_engine'])) { |
||
76 | $defaultEngine = $config['export']['default_engine']; |
||
77 | |||
78 | if (DirectDownloadEngine::NAME === $defaultEngine) { |
||
79 | $container->setAlias(EngineInterface::class, DirectDownloadEngine::class); |
||
80 | } elseif (BackgroundEmailEngine::class === $defaultEngine) { |
||
81 | $container->setAlias(EngineInterface::class, BackgroundEmailEngine::class); |
||
82 | } elseif (BackgroundDownloadEngine::NAME === $defaultEngine) { |
||
83 | $container->setAlias(EngineInterface::class, BackgroundDownloadEngine::class); |
||
84 | } |
||
85 | } |
||
86 | |||
87 | if (isset($config['export']['user_provider'])) { |
||
88 | if (!$container->hasDefinition($config['export']['user_provider'])) { |
||
89 | throw new MissingDependencyException(sprintf("The service '%s' for user provider for the export system", $config['export']['user_provider'])); |
||
90 | } |
||
91 | $container->setAlias('parthenon.export.user_provider', $config['export']['user_provider']); |
||
92 | } |
||
115 |