refactor: moving saveIntoFile to Helper function

This commit is contained in:
2022-12-23 00:25:50 -03:00
parent 228b3a06e1
commit 1788befec6

View File

@@ -45,7 +45,7 @@ class BilingualFile extends \BrunoFontes\Memsource\BaseApi
$errorMsg = $this->getError($filecontent); $errorMsg = $this->getError($filecontent);
throw new \Exception("Error downloading file: {$errorMsg}", 1); throw new \Exception("Error downloading file: {$errorMsg}", 1);
} }
$this->_saveIntoFile($filenames[$i], $filecontent); Helper::saveIntoFile($filenames[$i], $filecontent);
} }
return $filenames; return $filenames;
} }
@@ -66,17 +66,6 @@ class BilingualFile extends \BrunoFontes\Memsource\BaseApi
return ['jobs' => $convertedArray]; 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 * Upload a bilingual file to Memsource
* *