Skip to content

Commit 9ce9acd

Browse files
committed
Update Dumper
1 parent 483bcff commit 9ce9acd

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/Dumper.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,42 @@ public function prepareCreateTables()
143143
return (!$this->createTables) ? '--data-only' : '';
144144
}
145145
}
146+
147+
public function getDumpCommand(string $credentialFile = '', $destinationPath = '')
148+
{
149+
$destinationPath = !empty($destinationPath) ? $destinationPath : $this->destinationPath;
150+
switch (strtolower($this->getDumperClassName())) {
151+
case 'mysqldumper':
152+
$dumpCommand = $this->prepareDumpCommand($credentialFile, $destinationPath);
153+
break;
154+
default:
155+
$dumpCommand = $this->prepareDumpCommand($destinationPath);
156+
break;
157+
}
158+
159+
return $this->removeExtraSpaces($dumpCommand);
160+
}
161+
162+
public function getRestoreCommand(string $credentialFile = '', string $filePath = '')
163+
{
164+
$filePath = !empty($filePath) ? '"' . $filePath : $this->restorePath;
165+
switch (strtolower($this->getDumperClassName())) {
166+
case 'mysqldumper':
167+
$restoreCommand = $this->prepareRestoreCommand($credentialFile, $filePath);
168+
break;
169+
default:
170+
$restoreCommand = $this->prepareRestoreCommand($filePath);
171+
break;
172+
}
173+
174+
return $this->removeExtraSpaces($restoreCommand);
175+
}
176+
177+
public function getDumperClassName()
178+
{
179+
$classWithNamespace = static::class;
180+
$partials = explode("\\", $classWithNamespace);
181+
$className = end($partials);
182+
return $className;
183+
}
146184
}

src/Traits/DumperTrait.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -233,36 +233,6 @@ public function getRestorePath()
233233
return $this->restorePath;
234234
}
235235

236-
public function getDumpCommand(string $credentialFile = '', $destinationPath = '')
237-
{
238-
$destinationPath = !empty($destinationPath) ? $destinationPath : $this->destinationPath;
239-
switch (strtolower($this->getDumperClassName())) {
240-
case 'mysqldumper':
241-
$dumpCommand = $this->prepareDumpCommand($credentialFile, $destinationPath);
242-
break;
243-
default:
244-
$dumpCommand = $this->prepareDumpCommand($destinationPath);
245-
break;
246-
}
247-
248-
return $this->removeExtraSpaces($dumpCommand);
249-
}
250-
251-
public function getRestoreCommand(string $credentialFile = '', string $filePath = '')
252-
{
253-
$filePath = !empty($filePath) ? '"' . $filePath : $this->restorePath;
254-
switch (strtolower($this->getDumperClassName())) {
255-
case 'mysqldumper':
256-
$restoreCommand = $this->prepareRestoreCommand($credentialFile, $filePath);
257-
break;
258-
default:
259-
$restoreCommand = $this->prepareRestoreCommand($filePath);
260-
break;
261-
}
262-
263-
return $this->removeExtraSpaces($restoreCommand);
264-
}
265-
266236
public function removeExtraSpaces(string $str)
267237
{
268238
return preg_replace('/\s+/', ' ', $str);
@@ -277,12 +247,4 @@ public function quoteCommand(string $command)
277247
{
278248
return static::isWindows() ? "\"{$command}\"" : "'{$command}'";
279249
}
280-
281-
public function getDumperClassName()
282-
{
283-
$classWithNamespace = static::class;
284-
$partials = explode("\\", $classWithNamespace);
285-
$className = end($partials);
286-
return $className;
287-
}
288250
}

0 commit comments

Comments
 (0)