:octocat: simplify base64 URI creation

This commit is contained in:
codemasher
2021-01-20 16:19:48 +01:00
parent abf6c2fd94
commit e06c4a38f7
6 changed files with 16 additions and 10 deletions
+8 -2
View File
@@ -14,8 +14,7 @@ namespace chillerlan\QRCode\Output;
use chillerlan\QRCode\{Data\QRMatrix, QRCode};
use chillerlan\Settings\SettingsContainerInterface;
use function call_user_func_array, dirname, file_put_contents, get_called_class, in_array, is_writable, sprintf;
use function base64_encode, call_user_func_array, dirname, file_put_contents, get_called_class, in_array, is_writable, sprintf;
/**
* common output abstract
@@ -92,6 +91,13 @@ abstract class QROutputAbstract implements QROutputInterface{
*/
abstract protected function setModuleValues():void;
/**
* Returns a base64 data URI for the given string and mime type
*/
protected function base64encode(string $data, string $mime):string{
return sprintf('data:%s;base64,%s', $mime, base64_encode($data));
}
/**
* saves the qr data to a file
*