Skip to content

Commit ae1aa8a

Browse files
committed
Update Dumper
1 parent 13bbe1a commit ae1aa8a

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

src/Dumper.php

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

src/Traits/PrepareOptionsTrait.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -77,42 +77,4 @@ public function prepareIgnoreTables()
7777
return (count($this->ignoreTables) > 0) ? '-T ' . implode(' -T ', $this->ignoreTables) : '';
7878
}
7979
}
80-
81-
public function getDumpCommand(string $credentialFile = '', $destinationPath = '')
82-
{
83-
$destinationPath = !empty($destinationPath) ? $destinationPath : $this->destinationPath;
84-
switch (strtolower($this->getDumperClassName())) {
85-
case 'mysqldumper':
86-
$dumpCommand = $this->prepareDumpCommand($credentialFile, $destinationPath);
87-
break;
88-
default:
89-
$dumpCommand = $this->prepareDumpCommand($destinationPath);
90-
break;
91-
}
92-
93-
return $this->removeExtraSpaces($dumpCommand);
94-
}
95-
96-
public function getRestoreCommand(string $credentialFile = '', string $filePath = '')
97-
{
98-
$filePath = !empty($filePath) ? '"' . $filePath : $this->restorePath;
99-
switch (strtolower($this->getDumperClassName())) {
100-
case 'mysqldumper':
101-
$restoreCommand = $this->prepareRestoreCommand($credentialFile, $filePath);
102-
break;
103-
default:
104-
$restoreCommand = $this->prepareRestoreCommand($filePath);
105-
break;
106-
}
107-
108-
return $this->removeExtraSpaces($restoreCommand);
109-
}
110-
111-
public function getDumperClassName()
112-
{
113-
$classWithNamespace = static::class;
114-
$partials = explode("\\", $classWithNamespace);
115-
$className = end($partials);
116-
return $className;
117-
}
11880
}

0 commit comments

Comments
 (0)