| Conditions | 6 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 31 |
| 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 |
||
| 20 | public function register(Application $app) |
||
| 21 | { |
||
| 22 | $app['db.migrations.namespace'] = 'DoctrineMigrations'; |
||
| 23 | $app['db.migrations.path'] = null; |
||
| 24 | $app['db.migrations.table_name'] = null; |
||
| 25 | $app['db.migrations.name'] = null; |
||
| 26 | |||
| 27 | $app['dispatcher']->addListener(ConsoleEvents::INIT, function (ConsoleEvent $event) use ($app) { |
||
| 28 | $application = $event->getApplication(); |
||
| 29 | |||
| 30 | $helpers = array('dialog' => new DialogHelper()); |
||
| 31 | |||
| 32 | if (isset($app['orm.em'])) { |
||
| 33 | $helpers['em'] = new EntityManagerHelper($app['orm.em']); |
||
| 34 | } |
||
| 35 | |||
| 36 | $helperSet = new HelperSet($helpers); |
||
| 37 | |||
| 38 | $application->setHelperSet($helperSet); |
||
| 39 | |||
| 40 | $config = new Configuration($app['db']); |
||
| 41 | $config->setMigrationsNamespace($app['db.migrations.namespace']); |
||
| 42 | |||
| 43 | if ($app['db.migrations.path']) { |
||
| 44 | $config->setMigrationsDirectory($app['db.migrations.path']); |
||
| 45 | $config->registerMigrationsFromDirectory($app['db.migrations.path']); |
||
| 46 | } |
||
| 47 | |||
| 48 | if ($app['db.migrations.name']) { |
||
| 49 | $config->setName($app['db.migrations.name']); |
||
| 50 | } |
||
| 51 | |||
| 52 | if ($app['db.migrations.table_name']) { |
||
| 53 | $config->setMigrationsTableName($app['db.migrations.table_name']); |
||
| 54 | } |
||
| 55 | |||
| 56 | $commands = array( |
||
| 57 | new Command\DiffCommand(), |
||
| 58 | new Command\ExecuteCommand(), |
||
| 59 | new Command\GenerateCommand(), |
||
| 60 | new Command\MigrateCommand(), |
||
| 61 | new Command\StatusCommand(), |
||
| 62 | new Command\VersionCommand(), |
||
| 63 | ); |
||
| 64 | |||
| 65 | foreach ($commands as $command) { |
||
| 66 | /** @var \Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand $command */ |
||
| 67 | $command->setMigrationConfiguration($config); |
||
| 68 | $application->add($command); |
||
| 69 | } |
||
| 70 | }); |
||
| 71 | } |
||
| 72 | |||
| 81 |