ajout string_reader

This commit is contained in:
Jephté Clain 2025-06-16 17:56:16 +04:00
parent d704ce8c07
commit 04e7dab54e

View File

@ -117,4 +117,18 @@ class file {
} }
return $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;
}
} }