Completed
Push — master ( dbcb7a...819d20 )
by Mark
14s queued 11s
created
src/Migrator.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -8,68 +8,68 @@
 block discarded – undo
8 8
 
9 9
 class Migrator extends M
10 10
 {
11
-    /**
12
-     * Get all of the migration files in a given path.
13
-     *
14
-     * @param  string  $path
15
-     * @param  bool  $recursive
16
-     * @return array
17
-     */
18
-    public function getMigrationFiles($paths = [], $recursive = true)
19
-    {
20
-        if ($recursive) {
21
-            $paths = $this->getRecursiveFolders($paths);
22
-        }
11
+	/**
12
+	 * Get all of the migration files in a given path.
13
+	 *
14
+	 * @param  string  $path
15
+	 * @param  bool  $recursive
16
+	 * @return array
17
+	 */
18
+	public function getMigrationFiles($paths = [], $recursive = true)
19
+	{
20
+		if ($recursive) {
21
+			$paths = $this->getRecursiveFolders($paths);
22
+		}
23 23
 
24
-        $files = parent::getMigrationFiles($paths);
24
+		$files = parent::getMigrationFiles($paths);
25 25
 
26
-        return $files;
27
-    }
26
+		return $files;
27
+	}
28 28
 
29
-    /**
30
-     * Get all subdirectories located in an array of folders.
31
-     *
32
-     * @param  array  $folders
33
-     * @return array
34
-     */
35
-    public function getRecursiveFolders($folders)
36
-    {
37
-        if (! is_array($folders)) {
38
-            $folders = [$folders];
39
-        }
29
+	/**
30
+	 * Get all subdirectories located in an array of folders.
31
+	 *
32
+	 * @param  array  $folders
33
+	 * @return array
34
+	 */
35
+	public function getRecursiveFolders($folders)
36
+	{
37
+		if (! is_array($folders)) {
38
+			$folders = [$folders];
39
+		}
40 40
 
41
-        $paths = [];
41
+		$paths = [];
42 42
 
43
-        foreach ($folders as $folder) {
44
-            $iter = new Iterator(
45
-                new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS),
46
-                Iterator::SELF_FIRST,
47
-                Iterator::CATCH_GET_CHILD // Ignore "Permission denied"
48
-            );
43
+		foreach ($folders as $folder) {
44
+			$iter = new Iterator(
45
+				new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS),
46
+				Iterator::SELF_FIRST,
47
+				Iterator::CATCH_GET_CHILD // Ignore "Permission denied"
48
+			);
49 49
 
50
-            $subPaths = [$folder];
51
-            foreach ($iter as $path => $dir) {
52
-                if ($dir->isDir()) {
53
-                    $subPaths[] = $path;
54
-                }
55
-            }
50
+			$subPaths = [$folder];
51
+			foreach ($iter as $path => $dir) {
52
+				if ($dir->isDir()) {
53
+					$subPaths[] = $path;
54
+				}
55
+			}
56 56
 
57
-            $paths = array_merge($paths, $subPaths);
58
-        }
57
+			$paths = array_merge($paths, $subPaths);
58
+		}
59 59
 
60
-        return $paths;
61
-    }
60
+		return $paths;
61
+	}
62 62
 
63
-    /**
64
-     * Add date folders to migrations path.
65
-     *
66
-     * @param  string  $file
67
-     * @return string
68
-     */
69
-    public function getDateFolderStructure($file)
70
-    {
71
-        $parts = explode('_', $file);
63
+	/**
64
+	 * Add date folders to migrations path.
65
+	 *
66
+	 * @param  string  $file
67
+	 * @return string
68
+	 */
69
+	public function getDateFolderStructure($file)
70
+	{
71
+		$parts = explode('_', $file);
72 72
 
73
-        return $parts[0].'/'.$parts[1].'/';
74
-    }
73
+		return $parts[0].'/'.$parts[1].'/';
74
+	}
75 75
 }
Please login to merge, or discard this patch.
src/Commands/MigrateOrganise.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -8,84 +8,84 @@
 block discarded – undo
8 8
 
9 9
 class MigrateOrganise extends BaseCommand
10 10
 {
11
-    /**
12
-     * The console command name.
13
-     *
14
-     * @var string
15
-     */
16
-    protected $name = 'migrate:organise';
11
+	/**
12
+	 * The console command name.
13
+	 *
14
+	 * @var string
15
+	 */
16
+	protected $name = 'migrate:organise';
17 17
 
18
-    /**
19
-     * The console command description.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $description = 'Move migrations into a yyyy/mm folder structure';
18
+	/**
19
+	 * The console command description.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $description = 'Move migrations into a yyyy/mm folder structure';
24 24
 
25
-    /**
26
-     * The migrator instance.
27
-     *
28
-     * @var \Jaybizzle\MigrationsOrganiser\Migrator
29
-     */
30
-    protected $migrator;
25
+	/**
26
+	 * The migrator instance.
27
+	 *
28
+	 * @var \Jaybizzle\MigrationsOrganiser\Migrator
29
+	 */
30
+	protected $migrator;
31 31
 
32
-    /**
33
-     * The filesystem instance.
34
-     *
35
-     * @var \Illuminate\Filesystem\Filesystem
36
-     */
37
-    protected $files;
32
+	/**
33
+	 * The filesystem instance.
34
+	 *
35
+	 * @var \Illuminate\Filesystem\Filesystem
36
+	 */
37
+	protected $files;
38 38
 
39
-    /**
40
-     * Create a new migrator instance.
41
-     *
42
-     * @param  \Illuminate\Filesystem\Filesystem  $files
43
-     * @param  \Illuminate\Database\Migrations\Migrator  $migrator
44
-     */
45
-    public function __construct(Filesystem $files, Migrator $migrator)
46
-    {
47
-        parent::__construct();
48
-        $this->migrator = $migrator;
49
-        $this->files = $files;
50
-    }
39
+	/**
40
+	 * Create a new migrator instance.
41
+	 *
42
+	 * @param  \Illuminate\Filesystem\Filesystem  $files
43
+	 * @param  \Illuminate\Database\Migrations\Migrator  $migrator
44
+	 */
45
+	public function __construct(Filesystem $files, Migrator $migrator)
46
+	{
47
+		parent::__construct();
48
+		$this->migrator = $migrator;
49
+		$this->files = $files;
50
+	}
51 51
 
52
-    /**
53
-     * Fire the command. (Compatibility for < 5.5).
54
-     */
55
-    public function fire()
56
-    {
57
-        $this->handle();
58
-    }
52
+	/**
53
+	 * Fire the command. (Compatibility for < 5.5).
54
+	 */
55
+	public function fire()
56
+	{
57
+		$this->handle();
58
+	}
59 59
 
60
-    /**
61
-     * Create date folder structure and move migrations into.
62
-     *
63
-     * @return void
64
-     */
65
-    public function handle()
66
-    {
67
-        $basePath = $this->getMigrationPath();
68
-        $migrations = $this->migrator->getMigrationFiles($basePath, false);
69
-        $count = count($migrations);
60
+	/**
61
+	 * Create date folder structure and move migrations into.
62
+	 *
63
+	 * @return void
64
+	 */
65
+	public function handle()
66
+	{
67
+		$basePath = $this->getMigrationPath();
68
+		$migrations = $this->migrator->getMigrationFiles($basePath, false);
69
+		$count = count($migrations);
70 70
 
71
-        if ($count == 0) {
72
-            $this->comment('No migrations to move');
71
+		if ($count == 0) {
72
+			$this->comment('No migrations to move');
73 73
 
74
-            return;
75
-        }
74
+			return;
75
+		}
76 76
 
77
-        foreach ($migrations as $migration_name => $migration_path) {
78
-            $datePath = $this->migrator->getDateFolderStructure($migration_name);
77
+		foreach ($migrations as $migration_name => $migration_path) {
78
+			$datePath = $this->migrator->getDateFolderStructure($migration_name);
79 79
 
80
-            // Create folder if it does not already exist
81
-            if (! $this->files->exists($basePath.'/'.$datePath)) {
82
-                $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true);
83
-            }
80
+			// Create folder if it does not already exist
81
+			if (! $this->files->exists($basePath.'/'.$datePath)) {
82
+				$this->files->makeDirectory($basePath.'/'.$datePath, 0775, true);
83
+			}
84 84
 
85
-            // Move the migration into its new folder
86
-            $this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php');
87
-        }
85
+			// Move the migration into its new folder
86
+			$this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php');
87
+		}
88 88
 
89
-        $this->info('Migrations organised successfully ('.$count.' migrations moved)');
90
-    }
89
+		$this->info('Migrations organised successfully ('.$count.' migrations moved)');
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/Commands/MigrateDisorganise.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -9,126 +9,126 @@
 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
-     * Fire the command. (Compatibility for < 5.5).
60
-     */
61
-    public function fire()
62
-    {
63
-        $this->handle();
64
-    }
65
-
66
-    /**
67
-     * Create date folder structure and move migrations into.
68
-     *
69
-     * @return void
70
-     */
71
-    public function handle()
72
-    {
73
-        $this->basePath = $this->getMigrationPath();
74
-        $migrations = $this->migrator->getMigrationFiles($this->basePath);
75
-        $count = count($migrations);
76
-
77
-        if ($count == 0) {
78
-            $this->comment('No migrations to move');
79
-
80
-            return;
81
-        }
82
-
83
-        foreach ($migrations as $migration_name => $migration_path) {
84
-            $datePath = $this->migrator->getDateFolderStructure($migration_name);
85
-            // Move the migration into base migration folder
86
-            $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php');
87
-        }
88
-
89
-        $this->info('Migrations disorganised successfully ('.$count.' migrations moved)');
90
-        $this->cleanup();
91
-    }
92
-
93
-    /**
94
-     * Decide whether or not to delete directories.
95
-     *
96
-     * @return void
97
-     */
98
-    public function cleanup()
99
-    {
100
-        if ($this->option('force')) {
101
-            $this->deleteDirs();
102
-        } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
103
-            $this->deleteDirs();
104
-        }
105
-    }
106
-
107
-    /**
108
-     * Delete subdirectories in the migrations folder.
109
-     *
110
-     * @return void
111
-     */
112
-    public function deleteDirs()
113
-    {
114
-        $dirs = $this->files->directories($this->basePath);
115
-
116
-        foreach ($dirs as $dir) {
117
-            $this->files->deleteDirectory($dir);
118
-        }
119
-
120
-        $this->info('Subdirectories deleted');
121
-    }
122
-
123
-    /**
124
-     * Get the console command options.
125
-     *
126
-     * @return array
127
-     */
128
-    protected function getOptions()
129
-    {
130
-        return [
131
-            ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'],
132
-        ];
133
-    }
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
+	 * Fire the command. (Compatibility for < 5.5).
60
+	 */
61
+	public function fire()
62
+	{
63
+		$this->handle();
64
+	}
65
+
66
+	/**
67
+	 * Create date folder structure and move migrations into.
68
+	 *
69
+	 * @return void
70
+	 */
71
+	public function handle()
72
+	{
73
+		$this->basePath = $this->getMigrationPath();
74
+		$migrations = $this->migrator->getMigrationFiles($this->basePath);
75
+		$count = count($migrations);
76
+
77
+		if ($count == 0) {
78
+			$this->comment('No migrations to move');
79
+
80
+			return;
81
+		}
82
+
83
+		foreach ($migrations as $migration_name => $migration_path) {
84
+			$datePath = $this->migrator->getDateFolderStructure($migration_name);
85
+			// Move the migration into base migration folder
86
+			$this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php');
87
+		}
88
+
89
+		$this->info('Migrations disorganised successfully ('.$count.' migrations moved)');
90
+		$this->cleanup();
91
+	}
92
+
93
+	/**
94
+	 * Decide whether or not to delete directories.
95
+	 *
96
+	 * @return void
97
+	 */
98
+	public function cleanup()
99
+	{
100
+		if ($this->option('force')) {
101
+			$this->deleteDirs();
102
+		} elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
103
+			$this->deleteDirs();
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * Delete subdirectories in the migrations folder.
109
+	 *
110
+	 * @return void
111
+	 */
112
+	public function deleteDirs()
113
+	{
114
+		$dirs = $this->files->directories($this->basePath);
115
+
116
+		foreach ($dirs as $dir) {
117
+			$this->files->deleteDirectory($dir);
118
+		}
119
+
120
+		$this->info('Subdirectories deleted');
121
+	}
122
+
123
+	/**
124
+	 * Get the console command options.
125
+	 *
126
+	 * @return array
127
+	 */
128
+	protected function getOptions()
129
+	{
130
+		return [
131
+			['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'],
132
+		];
133
+	}
134 134
 }
Please login to merge, or discard this patch.