refactor: creating Helper class and moving saveIntoFile function

This commit is contained in:
Bruno F. Fontes 2022-12-23 00:24:41 -03:00
parent 1a3c690138
commit aab66427a8
Signed by: brunofontes
GPG Key ID: 4DAA810052CF68B6

19
src/Helper.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace BrunoFontes\Memsource;
class Helper
{
public static 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);
}
}
}