Code Duplication    Length = 20-20 lines in 2 locations

src/Databases/PostgreSql.php 1 location

@@ 37-56 (lines=20) @@
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
        $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile));
48
49
        if (! is_null($this->timeout)) {
50
            $process->setTimeout($this->timeout);
51
        }
52
53
        $process->run();
54
55
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
56
    }
57
58
    /**
59
     * Get the command that should be performed to dump the database.

src/Databases/MySql.php 1 location

@@ 93-112 (lines=20) @@
90
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
91
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
92
     */
93
    public function dumpToFile(string $dumpFile)
94
    {
95
        $this->guardAgainstIncompleteCredentials();
96
97
        $tempFileHandle = tmpfile();
98
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
99
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
100
101
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
102
103
        $process = new Process($command);
104
105
        if (! is_null($this->timeout)) {
106
            $process->setTimeout($this->timeout);
107
        }
108
109
        $process->run();
110
111
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
112
    }
113
114
    /**
115
     * Get the command that should be performed to dump the database.