registerMigrator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php namespace Codengine\CustomMigrations;
2
3
use Codengine\CustomMigrations\Commands\MigrateCommand;
4
use Codengine\CustomMigrations\Commands\RefreshCommand;
5
use Codengine\CustomMigrations\Commands\ResetCommand;
6
use Codengine\CustomMigrations\Commands\RollbackCommand;
7
use Illuminate\Database\MigrationServiceProvider;
8
use Illuminate\Support\ServiceProvider;
9
10
class CustomMigrationsServiceProvider extends MigrationServiceProvider {
11
	/**
12
	 * Register the migrator service.
13
	 *
14
	 * @return void
15
	 */
16
	protected function registerMigrator()
17
	{
18
		// The migrator is responsible for actually running and rollback the migration
19
		// files in the application. We'll pass in our database connection resolver
20
		// so the migrator can resolve any of these connections when it needs to.
21
		$this->app->singleton('migrator', function($app)
22
		{
23
			$repository = $app['migration.repository'];
24
			return new Migrator($repository, $app['db'], $app['files']);
25
		});
26
	}
27
28
	/**
29
	 * Register the "migrate" migration command.
30
	 *
31
	 * @return void
32
	 */
33
	protected function registerMigrateCommand()
34
	{
35
		$this->app->singleton('command.migrate', function($app)
36
		{
37
			$packagePath = $app['path.base'].'/vendor';
38
39
			return new MigrateCommand($app['migrator'], $packagePath);
0 ignored issues
show
Unused Code introduced by
The call to MigrateCommand::__construct() has too many arguments starting with $packagePath.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
40
		});
41
	}
42
43
	/**
44
	 * Register the "rollback" migration command.
45
	 *
46
	 * @return void
47
	 */
48
	protected function registerRollbackCommand()
49
	{
50
		$this->app->singleton('command.migrate.rollback', function($app)
51
		{
52
			return new RollbackCommand($app['migrator']);
53
		});
54
	}
55
56
	/**
57
	 * Register the "reset" migration command.
58
	 *
59
	 * @return void
60
	 */
61
	protected function registerResetCommand()
62
	{
63
		$this->app->singleton('command.migrate.reset', function($app)
64
		{
65
			return new ResetCommand($app['migrator']);
66
		});
67
	}
68
69
	/**
70
	 * Register the "refresh" migration command.
71
	 *
72
	 * @return void
73
	 */
74
	protected function registerRefreshCommand()
75
	{
76
		$this->app->singleton('command.migrate.refresh', function()
77
		{
78
			return new RefreshCommand;
79
		});
80
	}
81
}
82