mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2024-11-24 03:07:10 +00:00
refactor: moving saveIntoFile to Helper function
This commit is contained in:
parent
228b3a06e1
commit
1788befec6
@ -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
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user