Code Duplication    Length = 20-20 lines in 2 locations

src/Databases/MySql.php 1 location

@@ 157-176 (lines=20) @@
154
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
155
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
156
     */
157
    public function dumpToFile($dumpFile)
158
    {
159
        $this->guardAgainstIncompleteCredentials();
160
161
        $tempFileHandle = tmpfile();
162
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
163
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
164
165
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
166
167
        $process = new Process($command);
168
169
        if (!is_null($this->timeout)) {
170
            $process->setTimeout($this->timeout);
171
        }
172
173
        $process->run();
174
175
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
176
    }
177
178
    /**
179
     * Get the command that should be performed to dump the database.

src/Databases/PostgreSql.php 1 location

@@ 157-176 (lines=20) @@
154
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
155
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
156
     */
157
    public function dumpToFile($dumpFile)
158
    {
159
        $this->guardAgainstIncompleteCredentials();
160
161
        $command = $this->getDumpCommand($dumpFile);
162
163
        $tempFileHandle = tmpfile();
164
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
165
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
166
167
        $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile));
168
169
        if (!is_null($this->timeout)) {
170
            $process->setTimeout($this->timeout);
171
        }
172
173
        $process->run();
174
175
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
176
    }
177
178
    /**
179
     * Get the command that should be performed to dump the database.