Code Duplication    Length = 20-20 lines in 2 locations

src/Databases/MySql.php 1 location

@@ 225-244 (lines=20) @@
222
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
223
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
224
     */
225
    public function dumpToFile($dumpFile)
226
    {
227
        $this->guardAgainstIncompleteCredentials();
228
229
        $tempFileHandle = tmpfile();
230
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
231
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
232
233
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
234
235
        $process = new Process($command);
236
237
        if (!is_null($this->timeout)) {
238
            $process->setTimeout($this->timeout);
239
        }
240
241
        $process->run();
242
243
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
244
    }
245
246
    /**
247
     * Get the command that should be performed to dump the database.

src/Databases/PostgreSql.php 1 location

@@ 203-222 (lines=20) @@
200
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
201
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
202
     */
203
    public function dumpToFile($dumpFile)
204
    {
205
        $this->guardAgainstIncompleteCredentials();
206
207
        $command = $this->getDumpCommand($dumpFile);
208
209
        $tempFileHandle = tmpfile();
210
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
211
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
212
213
        $process = new Process($command, null, $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile));
214
215
        if (!is_null($this->timeout)) {
216
            $process->setTimeout($this->timeout);
217
        }
218
219
        $process->run();
220
221
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
222
    }
223
224
    /**
225
     * Get the command that should be performed to dump the database.