@@ -54,13 +54,13 @@ protected function prepareDumpCommand(string $destinationPath): string
54
54
'%smongodump %s %s %s %s %s %s %s %s ' ,
55
55
$ this ->dumpCommandPath ,
56
56
$ archive ,
57
- $ this ->getDatabaseOption (),
58
- $ this ->getUsernameOption (),
59
- $ this ->getPasswordOption (),
60
- $ this ->getHostOption (),
61
- $ this ->getPortOption (),
62
- $ this ->getCollectionOption (),
63
- $ this ->getAuthenticateDatabase ()
57
+ $ this ->prepareDatabase (),
58
+ $ this ->prepareUsername (),
59
+ $ this ->preparePassword (),
60
+ $ this ->prepareHost (),
61
+ $ this ->preparePort (),
62
+ $ this ->prepareCollection (),
63
+ $ this ->prepareAuthenticateDatabase ()
64
64
);
65
65
66
66
if ($ this ->uri ) {
@@ -69,7 +69,7 @@ protected function prepareDumpCommand(string $destinationPath): string
69
69
$ this ->dumpCommandPath ,
70
70
$ archive ,
71
71
$ this ->uri ,
72
- $ this ->getCollectionOption ()
72
+ $ this ->prepareCollection ()
73
73
);
74
74
}
75
75
@@ -80,74 +80,69 @@ protected function prepareDumpCommand(string $destinationPath): string
80
80
return "{$ dumpCommand } --out {$ destinationPath }" ;
81
81
}
82
82
83
- public function getDatabaseOption ()
83
+ protected function prepareRestoreCommand (string $ filePath ): string
84
+ {
85
+
86
+ $ archive = $ this ->isCompress ? "--gzip --archive " : "" ;
87
+
88
+ $ restoreCommand = sprintf ("%smongorestore %s %s %s %s %s " ,
89
+ $ this ->dumpCommandPath ,
90
+ $ archive ,
91
+ $ this ->prepareHost (),
92
+ $ this ->preparePort (),
93
+ $ this ->prepareUsername (),
94
+ $ this ->prepareAuthenticateDatabase ()
95
+ );
96
+
97
+ if ($ this ->uri ) {
98
+ $ restoreCommand = sprintf (
99
+ '%smongorestore %s --uri %s ' ,
100
+ $ this ->dumpCommandPath ,
101
+ $ archive ,
102
+ $ this ->uri
103
+ );
104
+ }
105
+
106
+ if ($ this ->isCompress ) {
107
+
108
+ return "{$ restoreCommand } < {$ filePath }" ;
109
+ }
110
+
111
+ return "{$ restoreCommand }{$ filePath }" ;
112
+ }
113
+
114
+ public function prepareDatabase ()
84
115
{
85
116
return !empty ($ this ->dbName ) ? "--db {$ this ->dbName }" : "" ;
86
117
}
87
118
88
- public function getUsernameOption ()
119
+ public function prepareUsername ()
89
120
{
90
121
return !empty ($ this ->username ) ? "--username {$ this ->username }" : "" ;
91
122
}
92
123
93
- public function getPasswordOption ()
124
+ public function preparePassword ()
94
125
{
95
126
return !empty ($ this ->password ) ? "--password {$ this ->password }" : "" ;
96
127
}
97
128
98
- public function getHostOption ()
129
+ public function prepareHost ()
99
130
{
100
131
return !empty ($ this ->host ) ? "--host {$ this ->host }" : "" ;
101
132
}
102
133
103
- public function getPortOption ()
134
+ public function preparePort ()
104
135
{
105
136
return !empty ($ this ->port ) ? "--port {$ this ->port }" : "" ;
106
137
}
107
138
108
- public function getAuthenticateDatabase ()
139
+ public function prepareAuthenticateDatabase ()
109
140
{
110
141
return !empty ($ this ->authenticationDatabase ) ? "--authenticationDatabase {$ this ->authenticationDatabase }" : "" ;
111
142
}
112
143
113
- public function getCollectionOption ()
144
+ public function prepareCollection ()
114
145
{
115
146
return !empty ($ this ->collection ) ? "--collection {$ this ->collection }" : "" ;
116
147
}
117
-
118
- public function getArchiveOption ()
119
- {
120
- return
121
- }
122
-
123
- protected function prepareRestoreCommand (string $ filePath ): string
124
- {
125
-
126
- $ archive = $ this ->isCompress ? "--gzip --archive " : "" ;
127
-
128
- $ restoreCommand = sprintf ("%smongorestore %s %s %s %s %s " ,
129
- $ this ->dumpCommandPath ,
130
- $ archive ,
131
- $ this ->getHostOption (),
132
- $ this ->getPortOption (),
133
- $ this ->getUsernameOption (),
134
- $ this ->getAuthenticateDatabase ()
135
- );
136
-
137
- if ($ this ->uri ) {
138
- $ restoreCommand = sprintf (
139
- '%smongorestore %s --uri %s ' ,
140
- $ this ->dumpCommandPath ,
141
- $ archive ,
142
- $ this ->uri
143
- );
144
- }
145
-
146
- if ($ this ->isCompress ) {
147
-
148
- return "{$ restoreCommand } < {$ filePath }" ;
149
- }
150
-
151
- return "{$ restoreCommand }{$ filePath }" ;
152
- }
153
148
}
0 commit comments