@@ -27,6 +27,10 @@ public static function create(array $options = [])
27
27
{
28
28
return new static ($ options );
29
29
}
30
+
31
+ abstract public function dump ();
32
+ abstract public function restore ();
33
+
30
34
/**
31
35
* @return \Symfony\Component\Process\Process
32
36
*/
@@ -58,8 +62,43 @@ protected function run()
58
62
}
59
63
}
60
64
61
- abstract public function dump ();
62
- abstract public function restore ();
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
+ }
63
102
64
103
public function removeExtraSpaces (string $ str )
65
104
{
0 commit comments