@@ -21,19 +21,20 @@ class MigrationHandler extends SetupHandler
21
21
*/
22
22
public function copyMigrationFiles (): void
23
23
{
24
- $ this ->destinationMigrationsDir = $ this ->distPath . 'Database/Eloquent-Migrations ' ;
25
- $ this ->sourceMigrationsDir = $ this ->sourcePath . 'Database/Eloquent-Migrations ' ;
24
+ $ this ->destinationMigrationsDir = $ this ->distPath . 'Database/Eloquent-Migrations ' ;
25
+ $ this ->sourceMigrationsDir = $ this ->sourcePath . 'Database/Eloquent-Migrations ' ;
26
26
27
- if (!$ this ->ensureDestinationDirectoryExists ()) {
27
+ if (! $ this ->ensureDestinationDirectoryExists ()) {
28
28
return ;
29
29
}
30
30
31
- if (!$ this ->validateSourceDirectoryExists ()) {
31
+ if (! $ this ->validateSourceDirectoryExists ()) {
32
32
return ;
33
33
}
34
34
35
- if (!$ this ->confirmProceedWithCopy ()) {
36
- $ this ->error (" Skipped copying migration files. " );
35
+ if (! $ this ->confirmProceedWithCopy ()) {
36
+ $ this ->error (' Skipped copying migration files. ' );
37
+
37
38
return ;
38
39
}
39
40
@@ -49,14 +50,16 @@ public function copyMigrationFiles(): void
49
50
*/
50
51
private function ensureDestinationDirectoryExists (): bool
51
52
{
52
- if (!is_dir ($ this ->destinationMigrationsDir )) {
53
+ if (! is_dir ($ this ->destinationMigrationsDir )) {
53
54
if (mkdir ($ this ->destinationMigrationsDir , 0777 , true )) {
54
- $ this ->write (CLI ::color (' Created: ' , 'green ' ) . clean_path ($ this ->destinationMigrationsDir ));
55
+ $ this ->write (CLI ::color (' Created: ' , 'green ' ). clean_path ($ this ->destinationMigrationsDir ));
55
56
} else {
56
- $ this ->error (' Failed to create directory: ' . clean_path ($ this ->destinationMigrationsDir ));
57
+ $ this ->error (' Failed to create directory: ' .clean_path ($ this ->destinationMigrationsDir ));
58
+
57
59
return false ;
58
60
}
59
61
}
62
+
60
63
return true ;
61
64
}
62
65
@@ -67,10 +70,12 @@ private function ensureDestinationDirectoryExists(): bool
67
70
*/
68
71
private function validateSourceDirectoryExists (): bool
69
72
{
70
- if (!is_dir ($ this ->sourceMigrationsDir )) {
71
- $ this ->error (' Source migration directory not found: ' . clean_path ($ this ->sourceMigrationsDir ));
73
+ if (! is_dir ($ this ->sourceMigrationsDir )) {
74
+ $ this ->error (' Source migration directory not found: ' .clean_path ($ this ->sourceMigrationsDir ));
75
+
72
76
return false ;
73
77
}
78
+
74
79
return true ;
75
80
}
76
81
@@ -86,9 +91,10 @@ private function confirmProceedWithCopy(): bool
86
91
}
87
92
88
93
$ promptMessage = sprintf (
89
- " Ready to copy migration files to %s. Continue? " ,
94
+ ' Ready to copy migration files to %s. Continue? ' ,
90
95
clean_path ($ this ->destinationMigrationsDir )
91
96
);
97
+
92
98
return $ this ->prompt ($ promptMessage , ['y ' , 'n ' ]) === 'y ' ;
93
99
}
94
100
@@ -99,7 +105,8 @@ private function processSourceMigrationFiles(): void
99
105
{
100
106
$ files = scandir ($ this ->sourceMigrationsDir );
101
107
if ($ files === false ) {
102
- $ this ->error (' Could not read source migration directory: ' . clean_path ($ this ->sourceMigrationsDir ));
108
+ $ this ->error (' Could not read source migration directory: ' .clean_path ($ this ->sourceMigrationsDir ));
109
+
103
110
return ;
104
111
}
105
112
@@ -109,40 +116,41 @@ private function processSourceMigrationFiles(): void
109
116
continue ;
110
117
}
111
118
$ migrationFilesFound = true ;
112
- $ sourceFile = $ this ->sourceMigrationsDir . '/ ' . $ file ;
113
- $ destFile = $ this ->destinationMigrationsDir . '/ ' . $ file ;
119
+ $ sourceFile = $ this ->sourceMigrationsDir . '/ ' . $ file ;
120
+ $ destFile = $ this ->destinationMigrationsDir . '/ ' . $ file ;
114
121
115
122
$ this ->copySingleMigrationFile ($ sourceFile , $ destFile );
116
123
}
117
124
118
- if (!$ migrationFilesFound ) {
125
+ if (! $ migrationFilesFound ) {
119
126
$ this ->write (CLI ::color (' No migration files found in the source directory. ' , 'yellow ' ));
120
127
}
121
128
}
122
129
123
130
/**
124
131
* Handles the copying of a single migration file, including overwrite confirmation.
125
132
*
126
- * @param string $sourceFile The full path to the source migration file.
127
- * @param string $destFile The full path to the destination migration file.
133
+ * @param string $sourceFile The full path to the source migration file.
134
+ * @param string $destFile The full path to the destination migration file.
128
135
*/
129
136
private function copySingleMigrationFile (string $ sourceFile , string $ destFile ): void
130
137
{
131
- if (file_exists ($ destFile ) && !$ this ->skipConfirmations ) {
138
+ if (file_exists ($ destFile ) && ! $ this ->skipConfirmations ) {
132
139
$ promptMessage = sprintf (
133
140
" File '%s' already exists. Overwrite? " ,
134
141
clean_path ($ destFile )
135
142
);
136
143
if ($ this ->prompt ($ promptMessage , ['n ' , 'y ' ]) === 'n ' ) {
137
- $ this ->write (CLI ::color (" Skipped: " , 'yellow ' ) . clean_path ($ destFile ));
144
+ $ this ->write (CLI ::color (' Skipped: ' , 'yellow ' ).clean_path ($ destFile ));
145
+
138
146
return ;
139
147
}
140
148
}
141
149
142
150
if (copy ($ sourceFile , $ destFile )) {
143
- $ this ->write (CLI ::color (' Copied: ' , 'green ' ) . clean_path ($ destFile ));
151
+ $ this ->write (CLI ::color (' Copied: ' , 'green ' ). clean_path ($ destFile ));
144
152
} else {
145
- $ this ->error (' Error copying migration file: ' . basename ($ sourceFile ) . ' to ' . clean_path ($ destFile ));
153
+ $ this ->error (' Error copying migration file: ' . basename ($ sourceFile ). ' to ' . clean_path ($ destFile ));
146
154
}
147
155
}
148
- }
156
+ }
0 commit comments