@@ -27,6 +27,10 @@ public static function create(array $options = [])
2727 {
2828 return new static ($ options );
2929 }
30+
31+ abstract public function dump ();
32+ abstract public function restore ();
33+
3034 /**
3135 * @return \Symfony\Component\Process\Process
3236 */
@@ -58,8 +62,43 @@ protected function run()
5862 }
5963 }
6064
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+ }
63102
64103 public function removeExtraSpaces (string $ str )
65104 {
0 commit comments