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

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