Completed
Push — master ( 3c144f...281bde )
by Mark
02:45
created
src/Commands/MigrateDisorganise.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -9,118 +9,118 @@
 block discarded – undo
9 9
 
10 10
 class MigrateDisorganise extends BaseCommand
11 11
 {
12
-    /**
13
-     * The console command name.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $name = 'migrate:disorganise';
18
-
19
-    /**
20
-     * The console command description.
21
-     *
22
-     * @var string
23
-     */
24
-    protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder';
25
-
26
-    /**
27
-     * The migrator instance.
28
-     *
29
-     * @var \Jaybizzle\MigrationsOrganiser\Migrator
30
-     */
31
-    protected $migrator;
32
-
33
-    /**
34
-     * The filesystem instance.
35
-     *
36
-     * @var \Illuminate\Filesystem\Filesystem
37
-     */
38
-    protected $files;
39
-
40
-    /**
41
-     * The basePath for the migrations.
42
-     */
43
-    protected $basePath;
44
-
45
-    /**
46
-     * Create a new migrator instance.
47
-     *
48
-     * @param \Illuminate\Filesystem\Filesystem        $files
49
-     * @param \Illuminate\Database\Migrations\Migrator $migrator
50
-     */
51
-    public function __construct(Filesystem $files, Migrator $migrator)
52
-    {
53
-        parent::__construct();
54
-        $this->migrator = $migrator;
55
-        $this->files = $files;
56
-    }
57
-
58
-    /**
59
-     * Create date folder structure and move migrations into.
60
-     *
61
-     * @return void
62
-     */
63
-    public function fire()
64
-    {
65
-        $this->basePath = $this->getMigrationPath();
66
-        $migrations = $this->migrator->getMigrationFiles($this->basePath);
67
-        $count = count($migrations);
68
-
69
-        if ($count == 0) {
70
-            $this->comment('No migrations to move');
71
-
72
-            return;
73
-        }
74
-
75
-        foreach ($migrations as $migration_name => $migration_path) {
76
-            $datePath = $this->migrator->getDateFolderStructure($migration_name);
77
-            // Move the migration into base migration folder
78
-            $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php');
79
-        }
80
-
81
-        $this->info('Migrations disorganised successfully ('.$count.' migrations moved)');
82
-        $this->cleanup();
83
-    }
84
-
85
-    /**
86
-     * Decide whether or not to delete directories.
87
-     *
88
-     * @return void
89
-     */
90
-    public function cleanup()
91
-    {
92
-        if ($this->option('force')) {
93
-            $this->deleteDirs();
94
-        } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
95
-            $this->deleteDirs();
96
-        }
97
-    }
98
-
99
-    /**
100
-     * Delete subdirectories in the migrations folder.
101
-     *
102
-     * @return void
103
-     */
104
-    public function deleteDirs()
105
-    {
106
-        $dirs = $this->files->directories($this->basePath);
107
-
108
-        foreach ($dirs as $dir) {
109
-            $this->files->deleteDirectory($dir);
110
-        }
111
-
112
-        $this->info('Subdirectories deleted');
113
-    }
114
-
115
-    /**
116
-     * Get the console command options.
117
-     *
118
-     * @return array
119
-     */
120
-    protected function getOptions()
121
-    {
122
-        return [
123
-            ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'],
124
-        ];
125
-    }
12
+	/**
13
+	 * The console command name.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	protected $name = 'migrate:disorganise';
18
+
19
+	/**
20
+	 * The console command description.
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder';
25
+
26
+	/**
27
+	 * The migrator instance.
28
+	 *
29
+	 * @var \Jaybizzle\MigrationsOrganiser\Migrator
30
+	 */
31
+	protected $migrator;
32
+
33
+	/**
34
+	 * The filesystem instance.
35
+	 *
36
+	 * @var \Illuminate\Filesystem\Filesystem
37
+	 */
38
+	protected $files;
39
+
40
+	/**
41
+	 * The basePath for the migrations.
42
+	 */
43
+	protected $basePath;
44
+
45
+	/**
46
+	 * Create a new migrator instance.
47
+	 *
48
+	 * @param \Illuminate\Filesystem\Filesystem        $files
49
+	 * @param \Illuminate\Database\Migrations\Migrator $migrator
50
+	 */
51
+	public function __construct(Filesystem $files, Migrator $migrator)
52
+	{
53
+		parent::__construct();
54
+		$this->migrator = $migrator;
55
+		$this->files = $files;
56
+	}
57
+
58
+	/**
59
+	 * Create date folder structure and move migrations into.
60
+	 *
61
+	 * @return void
62
+	 */
63
+	public function fire()
64
+	{
65
+		$this->basePath = $this->getMigrationPath();
66
+		$migrations = $this->migrator->getMigrationFiles($this->basePath);
67
+		$count = count($migrations);
68
+
69
+		if ($count == 0) {
70
+			$this->comment('No migrations to move');
71
+
72
+			return;
73
+		}
74
+
75
+		foreach ($migrations as $migration_name => $migration_path) {
76
+			$datePath = $this->migrator->getDateFolderStructure($migration_name);
77
+			// Move the migration into base migration folder
78
+			$this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php');
79
+		}
80
+
81
+		$this->info('Migrations disorganised successfully ('.$count.' migrations moved)');
82
+		$this->cleanup();
83
+	}
84
+
85
+	/**
86
+	 * Decide whether or not to delete directories.
87
+	 *
88
+	 * @return void
89
+	 */
90
+	public function cleanup()
91
+	{
92
+		if ($this->option('force')) {
93
+			$this->deleteDirs();
94
+		} elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
95
+			$this->deleteDirs();
96
+		}
97
+	}
98
+
99
+	/**
100
+	 * Delete subdirectories in the migrations folder.
101
+	 *
102
+	 * @return void
103
+	 */
104
+	public function deleteDirs()
105
+	{
106
+		$dirs = $this->files->directories($this->basePath);
107
+
108
+		foreach ($dirs as $dir) {
109
+			$this->files->deleteDirectory($dir);
110
+		}
111
+
112
+		$this->info('Subdirectories deleted');
113
+	}
114
+
115
+	/**
116
+	 * Get the console command options.
117
+	 *
118
+	 * @return array
119
+	 */
120
+	protected function getOptions()
121
+	{
122
+		return [
123
+			['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'],
124
+		];
125
+	}
126 126
 }
Please login to merge, or discard this patch.