| Conditions | 6 |
| Paths | 10 |
| Total Lines | 57 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 2 | Features | 4 |
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 |
||
| 28 | public function load(array $configs, ContainerBuilder $container) |
||
| 29 | { |
||
| 30 | $loader = new YamlFileLoader( |
||
| 31 | $container, |
||
| 32 | new FileLocator(__DIR__.'/../Resources/config') |
||
| 33 | ); |
||
| 34 | $loader->load('services.yml'); |
||
| 35 | |||
| 36 | // TODO replace with semantic configuration |
||
| 37 | $config = [ |
||
| 38 | 'db_driver' => 'mongodb' |
||
| 39 | ]; |
||
| 40 | $container->setParameter('twomartens.core.storage', $config['db_driver']); |
||
| 41 | |||
| 42 | if ('custom' !== $config['db_driver']) { |
||
| 43 | $loader->load(sprintf('%s.yml', $config['db_driver'])); |
||
| 44 | $container->setParameter('twomartens.core.backend_type_' . $config['db_driver'], true); |
||
| 45 | } |
||
| 46 | |||
| 47 | switch ($config['db_driver']) { |
||
| 48 | case 'orm': |
||
| 49 | $container->getDefinition('twomartens.core.group_listener') |
||
| 50 | ->addTag( |
||
| 51 | 'doctrine.event_subscriber', |
||
| 52 | [ |
||
| 53 | 'priority' => 10 |
||
| 54 | ] |
||
| 55 | ); |
||
| 56 | break; |
||
| 57 | |||
| 58 | case 'mongodb': |
||
| 59 | $container->getDefinition('twomartens.core.group_listener') |
||
| 60 | ->addTag( |
||
| 61 | 'doctrine_mongodb.odm.event_subscriber', |
||
| 62 | [ |
||
| 63 | 'priority' => 10 |
||
| 64 | ] |
||
| 65 | ); |
||
| 66 | break; |
||
| 67 | |||
| 68 | case 'couchdb': |
||
| 69 | $container->getDefinition('twomartens.core.group_listener') |
||
| 70 | ->addTag( |
||
| 71 | 'doctrine_couchdb.event_subscriber', |
||
| 72 | [ |
||
| 73 | 'priority' => 10 |
||
| 74 | ] |
||
| 75 | ); |
||
| 76 | break; |
||
| 77 | |||
| 78 | case 'propel': |
||
| 79 | break; |
||
| 80 | |||
| 81 | default: |
||
| 82 | break; |
||
| 83 | } |
||
| 84 | } |
||
| 85 | } |
||
| 86 |