From 04e7dab54ed0ba1512215c9be29fb0f2659199f1 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 16 Jun 2025 17:56:16 +0400 Subject: [PATCH] ajout string_reader --- php/src/file.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/php/src/file.php b/php/src/file.php index 6bd1928..a8175d4 100644 --- a/php/src/file.php +++ b/php/src/file.php @@ -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; + } }