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
1010
1111 private $ size = 0 ;
1212
13- public function __construct ($ body = "" , $ chunkSize = null )
13+ private $ chunkSize ;
14+
15+ public function __construct ($ body = "" , $ chunkSize = 8192 )
1416 {
1517 $ this ->size = strlen ($ body );
1618 $ this ->resource = fopen ('php://memory ' , 'rw+ ' );
@@ -22,6 +24,8 @@ public function __construct($body = "", $chunkSize = null)
2224
2325 fwrite ($ this ->resource , $ body );
2426 fseek ($ this ->resource , 0 );
27+
28+ $ this ->chunkSize = $ chunkSize ;
2529 }
2630
2731 public function __toString ()
@@ -89,7 +93,7 @@ public function isReadable()
8993
9094 public function read ($ length )
9195 {
92- return fread ($ this ->resource , $ length );
96+ return fread ($ this ->resource , min ( $ this -> chunkSize , $ length) );
9397 }
9498
9599 public function getContents ()
You can’t perform that action at this time.
0 commit comments