Conditions | 11 |
Paths | 32 |
Total Lines | 56 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 24 | ||
Bugs | 1 | Features | 14 |
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 |
||
18 | public function load(array $configs, ContainerBuilder $container) |
||
19 | { |
||
20 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
21 | $loader->load('runner.xml'); |
||
22 | $loader->load('helper.xml'); |
||
23 | |||
24 | $configuration = new Configuration(); |
||
25 | $config = $this->processConfiguration($configuration, $configs); |
||
26 | |||
27 | if (null === $config['view_template']) { |
||
28 | $config['view_template'] = __DIR__.'/../Resources/views/health/index.html.php'; |
||
29 | } |
||
30 | |||
31 | if ($config['enable_controller']) { |
||
32 | $container->setParameter(sprintf('%s.view_template', $this->getAlias()), $config['view_template']); |
||
33 | $loader->load('controller.xml'); |
||
34 | } |
||
35 | |||
36 | if ($config['mailer']['enabled']) { |
||
37 | $loader->load('helper/swift_mailer.xml'); |
||
38 | |||
39 | foreach ($config['mailer'] as $key => $value) { |
||
40 | $container->setParameter(sprintf('%s.mailer.%s', $this->getAlias(), $key), $value); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | $container->setParameter(sprintf('%s.default_group', $this->getAlias()), $config['default_group']); |
||
45 | |||
46 | if (empty($config['checks'])) { |
||
47 | return; |
||
48 | } |
||
49 | |||
50 | $checksLoaded = array(); |
||
51 | $containerParams = array(); |
||
52 | foreach ($config['checks']['groups'] as $group => $checks) { |
||
53 | if (empty($checks)) { |
||
54 | continue; |
||
55 | } |
||
56 | |||
57 | foreach ($checks as $check => $values) { |
||
58 | if (empty($values)) { |
||
59 | continue; |
||
60 | } |
||
61 | |||
62 | $containerParams['groups'][$group][$check] = $values; |
||
63 | $this->setParameters($container, $check, $group, $values); |
||
64 | |||
65 | if (!in_array($check, $checksLoaded)) { |
||
66 | $loader->load('checks/'.$check.'.xml'); |
||
67 | $checksLoaded[] = $check; |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | |||
72 | $container->setParameter(sprintf('%s.checks', $this->getAlias()), $containerParams); |
||
73 | } |
||
74 | |||
124 |