| Conditions | 8 |
| Paths | 30 |
| Total Lines | 63 |
| Code Lines | 36 |
| 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 |
||
| 24 | public function register(Container $container) |
||
| 25 | { |
||
| 26 | $container['doctrine_mongodb'] = function ($container) { |
||
| 27 | return new ManagerRegistry($container); |
||
| 28 | }; |
||
| 29 | |||
| 30 | if (isset($container['form.extensions'])) { |
||
| 31 | $container['form.extensions'] = $container->extend('form.extensions', function ($extensions, $container) { |
||
| 32 | $extensions[] = new DoctrineMongoDBExtension($container['doctrine_mongodb']); |
||
| 33 | |||
| 34 | return $extensions; |
||
| 35 | }); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (isset($container['validator']) && class_exists('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator')) { |
||
| 39 | $container['doctrine.orm.validator.unique_validator'] = function ($container) { |
||
| 40 | return new UniqueEntityValidator($container['doctrine_mongodb']); |
||
| 41 | }; |
||
| 42 | |||
| 43 | if (!isset($container['validator.validator_service_ids'])) { |
||
| 44 | $container['validator.validator_service_ids'] = array(); |
||
| 45 | } |
||
| 46 | |||
| 47 | $container['validator.validator_service_ids'] = array_merge( |
||
| 48 | $container['validator.validator_service_ids'], |
||
| 49 | array('doctrine_odm.mongodb.unique' => 'doctrine.orm.validator.unique_validator') |
||
| 50 | ); |
||
| 51 | |||
| 52 | $container['validator.object_initializers'] = $container->extend('validator.object_initializers', |
||
| 53 | function (array $objectInitializers) use ($container) { |
||
| 54 | $objectInitializers[] = new DoctrineInitializer($container['doctrine_mongodb']); |
||
| 55 | |||
| 56 | return $objectInitializers; |
||
| 57 | } |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | if (class_exists('Saxulum\\DoctrineOrmCommands\\Command\\CreateDatabaseDoctrineCommand')) { |
||
| 62 | if (isset($container['console'])) { |
||
| 63 | $container['console'] = $container->extend('console', function (ConsoleApplication $consoleApplication) use ($container) { |
||
| 64 | $helperSet = $consoleApplication->getHelperSet(); |
||
| 65 | $helperSet->set(new ManagerRegistryHelper($container['doctrine_mongodb']), 'doctrine_mongodb'); |
||
| 66 | |||
| 67 | return $consoleApplication; |
||
| 68 | }); |
||
| 69 | } |
||
| 70 | |||
| 71 | if (isset($container['console.commands'])) { |
||
| 72 | $container['console.commands'] = $container->extend('console.commands', function ($commands) use ($container) { |
||
| 73 | $commands[] = new CreateSchemaDoctrineODMCommand; |
||
| 74 | $commands[] = new UpdateSchemaDoctrineODMCommand; |
||
| 75 | $commands[] = new DropSchemaDoctrineODMCommand; |
||
| 76 | $commands[] = new QueryDoctrineODMCommand; |
||
| 77 | $commands[] = new ClearMetadataCacheDoctrineODMCommand; |
||
| 78 | $commands[] = new GenerateHydratorsDoctrineODMCommand; |
||
| 79 | $commands[] = new GenerateProxiesDoctrineODMCommand; |
||
| 80 | $commands[] = new InfoDoctrineODMCommand; |
||
| 81 | |||
| 82 | return $commands; |
||
| 83 | }); |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 |