| Conditions | 11 |
| Paths | 17 |
| Total Lines | 37 |
| Code Lines | 20 |
| 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 |
||
| 16 | public function process(ContainerBuilder $container) { |
||
| 17 | if (!$container->hasDefinition('drupal.drupal')) { |
||
| 18 | return; |
||
| 19 | } |
||
| 20 | |||
| 21 | $drupalDefinition = $container->getDefinition('drupal.drupal'); |
||
| 22 | foreach ($container->findTaggedServiceIds('drupal.driver') as $id => $attributes) { |
||
| 23 | foreach ($attributes as $attribute) { |
||
| 24 | if (isset($attribute['alias']) && $name = $attribute['alias']) { |
||
| 25 | $drupalDefinition->addMethodCall( |
||
| 26 | 'registerDriver', array($name, new Reference($id)) |
||
| 27 | ); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | // If this is Drupal Driver, then a core controller needs to be |
||
| 32 | // instantiated as well. |
||
| 33 | if ('drupal.driver.drupal' === $id) { |
||
| 34 | $drupalDriverDefinition = $container->getDefinition($id); |
||
| 35 | $availableCores = array(); |
||
| 36 | foreach ($container->findTaggedServiceIds('drupal.core') as $coreId => $coreAttributes) { |
||
| 37 | foreach ($coreAttributes as $attribute) { |
||
| 38 | if (isset($attribute['alias']) && $name = $attribute['alias']) { |
||
| 39 | $availableCores[$name] = $container->getDefinition($coreId); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | $drupalDriverDefinition->addMethodCall( |
||
| 44 | 'setCore', array($availableCores) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | $drupalDefinition->addMethodCall( |
||
| 50 | 'setDefaultDriverName', array($container->getParameter('drupal.drupal.default_driver')) |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |