src/AbstractSerializer.php
protected static function getLine(StreamInterface $stream)
    {
        $line    = '';
        $crFound = false;
        while (! $stream->eof()) {
            $char = $stream->read(1);

            if ($crFound && $char === self::LF) {
                $crFound = false;
                break;
            }

            // CR NOT followed by LF
            if ($crFound && $char !== self::LF) {
                throw new UnexpectedValueException('Unexpected carriage return detected');
            }

            // LF in isolation
            if (! $crFound && $char === self::LF) {
                throw new UnexpectedValueException('Unexpected line feed detected');
            }

            // CR found; do not append
            if ($char === self::CR) {
                $crFound = true;
                continue;
            }

            // Any other character: append
            $line .= $char;
        }

        // CR found at end of stream
        if ($crFound) {
            throw new UnexpectedValueException("Unexpected end of headers");
        }

        return $line;
    }
protected static function getLine(StreamInterface $stream)
    {
        $line    = '';
        $crFound = false;
        while (! $stream->eof()) {
            $char = $stream->read(1);

            if ($crFound && $char === self::LF) {
                $crFound = false;
                break;
            }

            // CR NOT followed by LF
            if ($crFound && $char !== self::LF) {
                throw new UnexpectedValueException('Unexpected carriage return detected');
            }

            // LF in isolation
            if (! $crFound && $char === self::LF) {
                throw new UnexpectedValueException('Unexpected line feed detected');
            }

            // CR found; do not append
            if ($char === self::CR) {
                $crFound = true;
                continue;
            }

            // Any other character: append
            $line .= $char;
        }

        // CR found at end of stream
        if ($crFound) {
            throw new UnexpectedValueException("Unexpected end of headers");
        }

        return $line;
    }
protected static function getLine ( StreamInterface $ stream ) { $ line = '' ; $ crFound = false ; while ( ! $ stream -> eof ( ) ) { $ char = $ stream -> read ( 1 ) ; if ( $ crFound && $ char === self :: LF ) { $ crFound = false ; break ; } // CR NOT followed by LF if ( $ crFound && $ char !== self :: LF ) { throw new UnexpectedValueException ( 'Unexpected carriage return detected' ) ; } // LF in isolation if ( ! $ crFound && $ char === self :: LF ) { throw new UnexpectedValueException ( 'Unexpected line feed detected' ) ; } // CR found; do not append if ( $ char === self :: CR ) { $ crFound = true ; continue ; } // Any other character: append $ line .= $ char ; } // CR found at end of stream if ( $ crFound ) { throw new UnexpectedValueException ( "Unexpected end of headers" ) ; } return $ line ; }
Retrieve a single line from the stream.

Retrieves a line from the stream; a line is defined as a sequence of
characters ending in a CRLF sequence.

@param StreamInterface $stream
@return string
@throws UnexpectedValueException if the sequence contains a CR or LF in
isolation, or ends in a CR.
Retrieve a single line from the stream .