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 = "")
4848 $ this ->run ();
4949 }
5050
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+
5167 protected function prepareDumpCommand (string $ destinationPath ): string
5268 {
5369 $ archive = $ this ->isCompress ? "--archive --gzip " : "" ;
Original file line number Diff line number Diff line change @@ -65,6 +65,22 @@ public function restore(string $restorePath = "")
6565 return $ this ;
6666 }
6767
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+
6884 protected function prepareDumpCommand (string $ credentialFile , string $ destinationPath ): string
6985 {
7086 $ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -43,6 +43,22 @@ public function restore(string $restorePath = "")
4343 $ this ->runCommand ();
4444 }
4545
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+
4662 protected function prepareDumpCommand (string $ destinationPath ): string
4763 {
4864 $ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -22,6 +22,22 @@ public function restore(string $restorePath = "")
2222 $ this ->run ();
2323 }
2424
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+
2541 protected function prepareDumpCommand (string $ destinationPath ): string
2642 {
2743 $ dumpCommand = sprintf (
Original file line number Diff line number Diff line change @@ -62,44 +62,6 @@ protected function run()
6262 }
6363 }
6464
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-
10365 public function removeExtraSpaces (string $ str )
10466 {
10567 return preg_replace ('/\s+/ ' , ' ' , $ str );
Original file line number Diff line number Diff line change @@ -77,4 +77,12 @@ public function prepareIgnoreTables()
7777 return (count ($ this ->ignoreTables ) > 0 ) ? '-T ' . implode (' -T ' , $ this ->ignoreTables ) : '' ;
7878 }
7979 }
80+
81+ public function getDumperClassName ()
82+ {
83+ $ classWithNamespace = static ::class;
84+ $ partials = explode ("\\" , $ classWithNamespace );
85+ $ className = end ($ partials );
86+ return $ className ;
87+ }
8088}
You can’t perform that action at this time.
0 commit comments