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

@@ 127-146 (lines=20) @@
124
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
125
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
126
     */
127
    public function dumpToFile(string $dumpFile)
128
    {
129
        $this->guardAgainstIncompleteCredentials();
130
131
        $tempFileHandle = tmpfile();
132
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
133
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
134
135
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
136
137
        $process = new Process($command);
138
139
        if (! is_null($this->timeout)) {
140
            $process->setTimeout($this->timeout);
141
        }
142
143
        $process->run();
144
145
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
146
    }
147
148
    public function addExtraOption(string $extraOption)
149
    {