refactor: moving saveIntoFile to Helper function

This commit is contained in:
Bruno F. Fontes 2022-12-23 00:25:50 -03:00
parent 228b3a06e1
commit 1788befec6
Signed by: brunofontes
GPG Key ID: 4DAA810052CF68B6

View File

@ -45,7 +45,7 @@ class BilingualFile extends \BrunoFontes\Memsource\BaseApi
$errorMsg = $this->getError($filecontent);
throw new \Exception("Error downloading file: {$errorMsg}", 1);
}
$this->_saveIntoFile($filenames[$i], $filecontent);
Helper::saveIntoFile($filenames[$i], $filecontent);
}
return $filenames;
}
@ -66,17 +66,6 @@ class BilingualFile extends \BrunoFontes\Memsource\BaseApi
return ['jobs' => $convertedArray];
}
private function _saveIntoFile(string $filename, string $filecontent): void
{
try {
$f = fopen($filename, 'w+');
fwrite($f, $filecontent);
fclose($f);
} catch (\Exception $e) {
throw new \Exception("File could not be saved: {$e->error}", 1);
}
}
/**
* Upload a bilingual file to Memsource
*