Code Duplication    Length = 16-18 lines in 2 locations

src/Databases/MySql.php 1 location

@@ 176-191 (lines=16) @@
173
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
174
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
175
     */
176
    public function dumpToFile(string $dumpFile)
177
    {
178
        $this->guardAgainstIncompleteCredentials();
179
180
        $tempFileHandle = tmpfile();
181
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
182
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
183
184
        $command = $this->getDumpCommand($dumpFile, $temporaryCredentialsFile);
185
186
        $process = Process::fromShellCommandline($command, null, null, null, $this->timeout);
187
188
        $process->run();
189
190
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
191
    }
192
193
    public function addExtraOption(string $extraOption)
194
    {

src/Databases/PostgreSql.php 1 location

@@ 40-57 (lines=18) @@
37
     * @throws \Spatie\DbDumper\Exceptions\CannotStartDump
38
     * @throws \Spatie\DbDumper\Exceptions\DumpFailed
39
     */
40
    public function dumpToFile(string $dumpFile)
41
    {
42
        $this->guardAgainstIncompleteCredentials();
43
44
        $command = $this->getDumpCommand($dumpFile);
45
46
        $tempFileHandle = tmpfile();
47
        fwrite($tempFileHandle, $this->getContentsOfCredentialsFile());
48
        $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
49
50
        $envVars = $this->getEnvironmentVariablesForDumpCommand($temporaryCredentialsFile);
51
52
        $process = Process::fromShellCommandline($command, null, $envVars, null, $this->timeout);
53
54
        $process->run();
55
56
        $this->checkIfDumpWasSuccessFul($process, $dumpFile);
57
    }
58
59
    /**
60
     * Get the command that should be performed to dump the database.