| Conditions | 15 |
| Paths | 81 |
| Total Lines | 55 |
| Code Lines | 35 |
| 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 |
||
| 54 | public function load(array $configs, ContainerBuilder $container) |
||
| 55 | { |
||
| 56 | $configuration = new Configuration($this->getAlias()); |
||
| 57 | /** @var $config array[] */ |
||
| 58 | $config = $this->processConfiguration($configuration, $configs); |
||
| 59 | |||
| 60 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
| 61 | $files = [ |
||
| 62 | 'components.yml', |
||
| 63 | 'parameters.yml', |
||
| 64 | 'services.yml', |
||
| 65 | ]; |
||
| 66 | foreach ($files as $file) { |
||
| 67 | if (file_exists(__DIR__.'/../Resources/config/'.$file)) { |
||
| 68 | $loader->load($file); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | foreach ($config['other'] as $key => $other) { |
||
| 73 | if (\is_array($other)) { |
||
| 74 | foreach ($other as $variable => $value) { |
||
| 75 | $container->setParameter($this->getAlias().'.'.$key.'.'.$variable, $config['other'][$key][$variable]); |
||
| 76 | } |
||
| 77 | } else { |
||
| 78 | $container->setParameter($this->getAlias().'.'.$key, $config['other'][$key]); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | foreach ($config['extensions'] as $key => $extension) { |
||
| 83 | if (!isset($extension['enabled']) || $extension['enabled'] !== true) { |
||
| 84 | continue; |
||
| 85 | } |
||
| 86 | if ($this->checkRequirements($key)) { |
||
| 87 | $iterator = 0; |
||
| 88 | /** @var $extension array */ |
||
| 89 | foreach ($extension as $variable => $value) { |
||
| 90 | $iterator++; |
||
| 91 | if ($iterator === 1) { |
||
| 92 | $files = [ |
||
| 93 | 'components.yml', |
||
| 94 | 'parameters.yml', |
||
| 95 | 'services.yml', |
||
| 96 | ]; |
||
| 97 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../'.ucfirst($key).'/Resources/config')); |
||
| 98 | foreach ($files as $file) { |
||
| 99 | if (file_exists(__DIR__.'/../'.ucfirst($key).'/Resources/config/'.$file)) { |
||
| 100 | $loader->load($file); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | } |
||
| 104 | $container->setParameter($this->getAlias().'.'.$key.'.'.$variable, $config['extensions'][$key][$variable]); |
||
| 105 | } |
||
| 106 | if ($component = $this->checkComponent($key)) { |
||
| 107 | /** @var $component ConfigureInterface */ |
||
| 108 | $component->configure($container, $this->getAlias()); |
||
| 109 | } |
||
| 114 |