Skip to content

Commit

Permalink
fix: static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed May 28, 2024
1 parent eaec992 commit 2d402e2
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/SQLLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ public function execute(): ProcessResult

$this->result = Process::command($command)->run();

$this->logs = file_get_contents($this->logPath) ?? '';
if ($this->logPath && File::exists($this->logPath)) {
$this->logs = File::get($this->logPath);
}

if ($this->deleteFiles) {
$this->deleteGeneratedFiles();
}

return $this->result;
return $this->result; // @phpstan-ignore-line
}

protected function buildCommand(): string
Expand Down Expand Up @@ -241,21 +243,20 @@ public function getSqlLoaderBinary(): string

protected function deleteGeneratedFiles(): void
{
$filesystem = $this->getDisk();
$filesystem->delete($this->getFile());
if ($this->logPath) {
unlink($this->logPath);
if ($this->logPath && File::exists($this->logPath)) {
File::delete($this->logPath);
}

if ($this->badFile) {
unlink($this->badFile);
if ($this->badFile && File::exists($this->badFile)) {
File::delete($this->badFile);
}

if ($this->discardFile) {
unlink($this->discardFile);
if ($this->discardFile && File::exists($this->discardFile)) {
File::delete($this->discardFile);
}

if ($this->controlFile) {
$filesystem = $this->getDisk();
if ($this->controlFile && $filesystem->exists($this->controlFile)) {
$filesystem->delete($this->controlFile);
}
}
Expand Down

0 comments on commit 2d402e2

Please sign in to comment.