File tree Expand file tree Collapse file tree 6 files changed +72
-38
lines changed Expand file tree Collapse file tree 6 files changed +72
-38
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,22 @@ public function restore(string $restorePath = "")
48
48
$ this ->run ();
49
49
}
50
50
51
+ public function getDumpCommand ($ destinationPath = '' )
52
+ {
53
+ $ destinationPath = !empty ($ destinationPath ) ? $ destinationPath : $ this ->destinationPath ;
54
+ $ dumpCommand = $ this ->prepareDumpCommand ($ destinationPath );
55
+
56
+ return $ this ->removeExtraSpaces ($ dumpCommand );
57
+ }
58
+
59
+ public function getRestoreCommand (string $ filePath = '' )
60
+ {
61
+ $ filePath = !empty ($ filePath ) ? '" ' . $ filePath : $ this ->restorePath ;
62
+ $ restoreCommand = $ this ->prepareRestoreCommand ($ filePath );
63
+
64
+ return $ this ->removeExtraSpaces ($ restoreCommand );
65
+ }
66
+
51
67
protected function prepareDumpCommand (string $ destinationPath ): string
52
68
{
53
69
$ archive = $ this ->isCompress ? "--archive --gzip " : "" ;
Original file line number Diff line number Diff line change @@ -65,6 +65,22 @@ public function restore(string $restorePath = "")
65
65
return $ this ;
66
66
}
67
67
68
+ public function getDumpCommand (string $ credentialFile = '' , $ destinationPath = '' )
69
+ {
70
+ $ destinationPath = !empty ($ destinationPath ) ? $ destinationPath : $ this ->destinationPath ;
71
+ $ dumpCommand = $ this ->prepareDumpCommand ($ credentialFile , $ destinationPath );
72
+
73
+ return $ this ->removeExtraSpaces ($ dumpCommand );
74
+ }
75
+
76
+ public function getRestoreCommand (string $ credentialFile = '' , string $ filePath = '' )
77
+ {
78
+ $ filePath = !empty ($ filePath ) ? '" ' . $ filePath : $ this ->restorePath ;
79
+ $ restoreCommand = $ this ->prepareRestoreCommand ($ credentialFile , $ filePath );
80
+
81
+ return $ this ->removeExtraSpaces ($ restoreCommand );
82
+ }
83
+
68
84
protected function prepareDumpCommand (string $ credentialFile , string $ destinationPath ): string
69
85
{
70
86
$ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -43,6 +43,22 @@ public function restore(string $restorePath = "")
43
43
$ this ->runCommand ();
44
44
}
45
45
46
+ public function getDumpCommand ($ destinationPath = '' )
47
+ {
48
+ $ destinationPath = !empty ($ destinationPath ) ? $ destinationPath : $ this ->destinationPath ;
49
+ $ dumpCommand = $ this ->prepareDumpCommand ($ destinationPath );
50
+
51
+ return $ this ->removeExtraSpaces ($ dumpCommand );
52
+ }
53
+
54
+ public function getRestoreCommand (string $ filePath = '' )
55
+ {
56
+ $ filePath = !empty ($ filePath ) ? '" ' . $ filePath : $ this ->restorePath ;
57
+ $ restoreCommand = $ this ->prepareRestoreCommand ($ filePath );
58
+
59
+ return $ this ->removeExtraSpaces ($ restoreCommand );
60
+ }
61
+
46
62
protected function prepareDumpCommand (string $ destinationPath ): string
47
63
{
48
64
$ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -22,6 +22,22 @@ public function restore(string $restorePath = "")
22
22
$ this ->run ();
23
23
}
24
24
25
+ public function getDumpCommand ($ destinationPath = '' )
26
+ {
27
+ $ destinationPath = !empty ($ destinationPath ) ? $ destinationPath : $ this ->destinationPath ;
28
+ $ dumpCommand = $ this ->prepareDumpCommand ($ destinationPath );
29
+
30
+ return $ this ->removeExtraSpaces ($ dumpCommand );
31
+ }
32
+
33
+ public function getRestoreCommand (string $ filePath = '' )
34
+ {
35
+ $ filePath = !empty ($ filePath ) ? '" ' . $ filePath : $ this ->restorePath ;
36
+ $ restoreCommand = $ this ->prepareRestoreCommand ($ filePath );
37
+
38
+ return $ this ->removeExtraSpaces ($ restoreCommand );
39
+ }
40
+
25
41
protected function prepareDumpCommand (string $ destinationPath ): string
26
42
{
27
43
$ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -62,44 +62,6 @@ protected function run()
62
62
}
63
63
}
64
64
65
- public function getDumpCommand (string $ credentialFile = '' , $ destinationPath = '' )
66
- {
67
- $ destinationPath = !empty ($ destinationPath ) ? $ destinationPath : $ this ->destinationPath ;
68
- switch (strtolower ($ this ->getDumperClassName ())) {
69
- case 'mysqldumper ' :
70
- $ dumpCommand = $ this ->prepareDumpCommand ($ credentialFile , $ destinationPath );
71
- break ;
72
- default :
73
- $ dumpCommand = $ this ->prepareDumpCommand ($ destinationPath );
74
- break ;
75
- }
76
-
77
- return $ this ->removeExtraSpaces ($ dumpCommand );
78
- }
79
-
80
- public function getRestoreCommand (string $ credentialFile = '' , string $ filePath = '' )
81
- {
82
- $ filePath = !empty ($ filePath ) ? '" ' . $ filePath : $ this ->restorePath ;
83
- switch (strtolower ($ this ->getDumperClassName ())) {
84
- case 'mysqldumper ' :
85
- $ restoreCommand = $ this ->prepareRestoreCommand ($ credentialFile , $ filePath );
86
- break ;
87
- default :
88
- $ restoreCommand = $ this ->prepareRestoreCommand ($ filePath );
89
- break ;
90
- }
91
-
92
- return $ this ->removeExtraSpaces ($ restoreCommand );
93
- }
94
-
95
- public function getDumperClassName ()
96
- {
97
- $ classWithNamespace = static ::class;
98
- $ partials = explode ("\\" , $ classWithNamespace );
99
- $ className = end ($ partials );
100
- return $ className ;
101
- }
102
-
103
65
public function removeExtraSpaces (string $ str )
104
66
{
105
67
return preg_replace ('/\s+/ ' , ' ' , $ str );
Original file line number Diff line number Diff line change @@ -77,4 +77,12 @@ public function prepareIgnoreTables()
77
77
return (count ($ this ->ignoreTables ) > 0 ) ? '-T ' . implode (' -T ' , $ this ->ignoreTables ) : '' ;
78
78
}
79
79
}
80
+
81
+ public function getDumperClassName ()
82
+ {
83
+ $ classWithNamespace = static ::class;
84
+ $ partials = explode ("\\" , $ classWithNamespace );
85
+ $ className = end ($ partials );
86
+ return $ className ;
87
+ }
80
88
}
You can’t perform that action at this time.
0 commit comments