ajout string_reader
This commit is contained in:
parent
d704ce8c07
commit
04e7dab54e
@ -117,4 +117,18 @@ class file {
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
static function string_reader(string $content, ?callable $func=null): MemoryStream {
|
||||
$file = new MemoryStream();
|
||||
$file->fwrite($content);
|
||||
$file->rewind();
|
||||
if ($func !== null) {
|
||||
try {
|
||||
$func($file);
|
||||
} finally {
|
||||
$file ->close();
|
||||
}
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user