2020class Decoder extends EventEmitter implements ReadableStreamInterface
2121{
2222 /**
23- * @var \Clue\React\NDJson\Decoder
23+ * @var NDJsonDecoder
2424 */
25- protected $ ndjson_decoder ;
25+ protected NDJsonDecoder $ ndjson_decoder ;
2626
2727 /**
2828 * @var bool Flag if stream is closed
2929 */
30- private $ closed = false ;
30+ private bool $ closed = false ;
3131
3232 /**
3333 * Decoder constructor.
3434 * @param ReadableStreamInterface $input
35+ * @param int $maxLength Max length of a JSON line
3536 */
36- public function __construct (ReadableStreamInterface $ input )
37+ public function __construct (ReadableStreamInterface $ input, int $ maxLength = 65536 )
3738 {
38- $ this ->ndjson_decoder = new NDJsonDecoder ($ input , true );
39+ $ this ->ndjson_decoder = new NDJsonDecoder ($ input , true , 512 , 0 , $ maxLength );
3940
4041 $ this ->ndjson_decoder ->on ('data ' , array ($ this , 'handleData ' ));
4142 $ this ->ndjson_decoder ->on ('end ' , array ($ this , 'handleEnd ' ));
@@ -46,7 +47,7 @@ public function __construct(ReadableStreamInterface $input)
4647 /**
4748 * Close the stream
4849 */
49- public function close ()
50+ public function close () : void
5051 {
5152 $ this ->closed = true ;
5253 $ this ->ndjson_decoder ->close ();
@@ -57,23 +58,23 @@ public function close()
5758 /**
5859 * @return bool
5960 */
60- public function isReadable ()
61+ public function isReadable () : bool
6162 {
6263 return $ this ->ndjson_decoder ->isReadable ();
6364 }
6465
6566 /**
6667 * Pause
6768 */
68- public function pause ()
69+ public function pause () : void
6970 {
7071 $ this ->ndjson_decoder ->pause ();
7172 }
7273
7374 /**
7475 * Resume
7576 */
76- public function resume ()
77+ public function resume () : void
7778 {
7879 $ this ->ndjson_decoder ->resume ();
7980 }
0 commit comments