Code Duplication    Length = 16-18 lines in 2 locations

src/Databases/PostgreSql.php 1 location

@@ 37-54 (lines=18) @@
34
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
35
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
36
     */
37
    public function dumpToFile(string $dumpFile)
38
    {
39
        $this->guardAgainstIncompleteCredentials();
40
41
        $command = $this->getDumpCommand($dumpFile);
42
43
        $tempFileHandle = tmpfile();
44
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
45
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
46
47
        $envVars = $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile);
48
49
        $process = Process::fromShellCommandline($command, null, $envVars, null, $this->timeout);
50
51
        $process->run();
52
53
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
54
    }
55
56
    /**
57
     * Get the command that should be performed to dump the database.

src/Databases/MySql.php 1 location

@@ 176-191 (lines=16) @@
173
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
174
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
175
     */
176
    public function dumpToFile(string $dumpFile)
177
    {
178
        $this->guardAgainstIncompleteCredentials();
179
180
        $tempFileHandle = tmpfile();
181
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
182
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
183
184
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
185
186
        $process = Process::fromShellCommandline($command, null, null, null, $this->timeout);
187
188
        $process->run();
189
190
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
191
    }
192
193
    public function addExtraOption(string $extraOption)
194
    {