File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ class MemoryStream implements StreamInterface
10
10
11
11
private $ size = 0 ;
12
12
13
- public function __construct ($ body = "" , $ chunkSize = null )
13
+ private $ chunkSize ;
14
+
15
+ public function __construct ($ body = "" , $ chunkSize = 8192 )
14
16
{
15
17
$ this ->size = strlen ($ body );
16
18
$ this ->resource = fopen ('php://memory ' , 'rw+ ' );
@@ -22,6 +24,8 @@ public function __construct($body = "", $chunkSize = null)
22
24
23
25
fwrite ($ this ->resource , $ body );
24
26
fseek ($ this ->resource , 0 );
27
+
28
+ $ this ->chunkSize = $ chunkSize ;
25
29
}
26
30
27
31
public function __toString ()
@@ -89,7 +93,7 @@ public function isReadable()
89
93
90
94
public function read ($ length )
91
95
{
92
- return fread ($ this ->resource , $ length );
96
+ return fread ($ this ->resource , min ( $ this -> chunkSize , $ length) );
93
97
}
94
98
95
99
public function getContents ()
You can’t perform that action at this time.
0 commit comments