public static function bufferedReader(StreamInterface $stream, $bufferSize = 8192)
	{
		if(!$stream->isReadable())
		{
			throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream)));
		}
		
		$buffer = '';
		
		while(!$stream->eof())
		{
			$buffer .= $stream->read($bufferSize);
			
			while(strlen($buffer) >= $bufferSize)
			{
				yield (string)substr($buffer, 0, $bufferSize);
				
				$buffer = (string)substr($buffer, $bufferSize);
			}
		}
		
		if($buffer !== '')
		{
			yield $buffer;
		}
	}
public static function bufferedReader(StreamInterface $stream, $bufferSize = 8192)
	{
		if(!$stream->isReadable())
		{
			throw new \InvalidArgumentException(sprintf('Stream is not readable: %s', get_class($stream)));
		}
		
		$buffer = '';
		
		while(!$stream->eof())
		{
			$buffer .= $stream->read($bufferSize);
			
			while(strlen($buffer) >= $bufferSize)
			{
				yield (string)substr($buffer, 0, $bufferSize);
				
				$buffer = (string)substr($buffer, $bufferSize);
			}
		}
		
		if($buffer !== '')
		{
			yield $buffer;
		}
	}
public static function bufferedReader ( StreamInterface $ stream , $ bufferSize = 8192 ) { if ( ! $ stream -> isReadable ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Stream is not readable: %s' , get_class ( $ stream ) ) ) ; } $ buffer = '' ; while ( ! $ stream -> eof ( ) ) { $ buffer .= $ stream -> read ( $ bufferSize ) ; while ( strlen ( $ buffer ) >= $ bufferSize ) { yield ( string ) substr ( $ buffer , 0 , $ bufferSize ) ; $ buffer = ( string ) substr ( $ buffer , $ bufferSize ) ; } } if ( $ buffer !== '' ) { yield $ buffer ; } }
Turn a stream into an iterator returning even-sized results.

@param StreamInterface $stream
@param int $bufferSize
@return \Iterator

@throws \InvalidArgumentException When the stream is not readable.
Turn a stream into an iterator returning even - sized results .