| Conditions | 15 |
| Paths | 126 |
| 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 |
||
| 26 | public function load(array $configs, ContainerBuilder $container) |
||
|
|
|||
| 27 | { |
||
| 28 | $configuration = new Configuration(); |
||
| 29 | $config = $this->processConfiguration($configuration, $configs); |
||
| 30 | |||
| 31 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
| 32 | $files = [ |
||
| 33 | 'components.yml', |
||
| 34 | 'parameters.yml', |
||
| 35 | 'services.yml', |
||
| 36 | ]; |
||
| 37 | foreach ($files as $file) { |
||
| 38 | if (file_exists(__DIR__.'/../Resources/config/'.$file)) { |
||
| 39 | $loader->load($file); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | foreach ($config['extensions'] as $key => $extension) { |
||
| 44 | $enabled = $iterator = 0; |
||
| 45 | $length = count($extension); |
||
| 46 | foreach ($extension as $variable => $value) { |
||
| 47 | $iterator++; |
||
| 48 | if ($variable == 'enabled' && $value) { |
||
| 49 | $files = [ |
||
| 50 | 'components.yml', |
||
| 51 | 'parameters.yml', |
||
| 52 | 'services.yml', |
||
| 53 | ]; |
||
| 54 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../'.ucfirst($key).'/Resources/config')); |
||
| 55 | foreach ($files as $file) { |
||
| 56 | if (file_exists(__DIR__.'/../'.ucfirst($key).'/Resources/config/'.$file)) { |
||
| 57 | $loader->load($file); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | $enabled = 1; |
||
| 61 | } |
||
| 62 | if ($enabled === 1) { |
||
| 63 | $container->setParameter('sludio_helper.'.$key.'.'.$variable, $config['extensions'][$key][$variable]); |
||
| 64 | } |
||
| 65 | if ($iterator === $length && $enabled === 1) { |
||
| 66 | $ext = new Extension($key); |
||
| 67 | if ($ext->getExtension()) { |
||
| 68 | $ext->configure($container); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | foreach ($config['other'] as $key => $other) { |
||
| 75 | foreach ($other as $variable => $value) { |
||
| 76 | $container->setParameter('sludio_helper.'.$key.'.'.$variable, $config['other'][$key][$variable]); |
||
| 77 | } |
||
| 80 | } |
Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.