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