Conditions | 16 |
Paths | 126 |
Total Lines | 54 |
Code Lines | 36 |
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 |
||
36 | public function load(array $configs, ContainerBuilder $container) |
||
37 | { |
||
38 | $configuration = new Configuration(); |
||
39 | $config = $this->processConfiguration($configuration, $configs); |
||
40 | |||
41 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
42 | $files = [ |
||
43 | 'components.yml', |
||
44 | 'parameters.yml', |
||
45 | 'services.yml', |
||
46 | ]; |
||
47 | foreach ($files as $file) { |
||
48 | if (file_exists(__DIR__.'/../Resources/config/'.$file)) { |
||
49 | $loader->load($file); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | foreach ($config['extensions'] as $key => $extension) { |
||
54 | $enabled = $iterator = 0; |
||
55 | $length = count($extension); |
||
56 | foreach ($extension as $variable => $value) { |
||
57 | $iterator++; |
||
58 | if ($variable == 'enabled' && $value) { |
||
59 | $files = [ |
||
60 | 'components.yml', |
||
61 | 'parameters.yml', |
||
62 | 'services.yml', |
||
63 | ]; |
||
64 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../'.ucfirst($key).'/Resources/config')); |
||
65 | foreach ($files as $file) { |
||
66 | if (file_exists(__DIR__.'/../'.ucfirst($key).'/Resources/config/'.$file)) { |
||
67 | $loader->load($file); |
||
68 | } |
||
69 | } |
||
70 | $enabled = 1; |
||
71 | } |
||
72 | if ($enabled === 1) { |
||
73 | $container->setParameter('sludio_helper.'.$key.'.'.$variable, $config['extensions'][$key][$variable]); |
||
74 | } |
||
75 | if ($iterator === $length && $enabled === 1) { |
||
76 | if ($ext = $this->checkExtension($key)) { |
||
77 | $ext->configure($container); |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | |||
83 | foreach ($config['other'] as $key => $other) { |
||
84 | if (is_array($other)) { |
||
85 | foreach ($other as $variable => $value) { |
||
86 | $container->setParameter('sludio_helper.'.$key.'.'.$variable, $config['other'][$key][$variable]); |
||
87 | } |
||
88 | } else { |
||
89 | $container->setParameter('sludio_helper.'.$key, $config['other'][$key]); |
||
90 | } |
||
93 | } |