We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c6155d commit 14e0ad4Copy full SHA for 14e0ad4
src/Helper/PhpHelper.php
@@ -9,9 +9,11 @@
9
10
namespace Toolkit\Stdlib\Helper;
11
12
+use RuntimeException;
13
use Toolkit\Stdlib\Obj\ObjectHelper;
14
use function array_sum;
15
use function explode;
16
+use function fopen;
17
use function is_array;
18
use function is_callable;
19
use function is_object;
@@ -50,6 +52,22 @@ public static function value($value)
50
52
return $value;
51
53
}
54
55
+ /**
56
+ * @param string $mode
57
+ *
58
+ * @return resource
59
+ */
60
+ public static function newMemoryStream(string $mode = 'rwb')
61
+ {
62
+ $handle = fopen('php://memory', $mode);
63
+
64
+ if (!is_resource($handle)) {
65
+ throw new RuntimeException('create temp memory stream fail');
66
+ }
67
68
+ return $handle;
69
70
71
/**
72
* get $_SERVER value
73
*
0 commit comments