src/Request/Serializer.php
public static function fromStream(StreamInterface $stream)
    {
        if (! $stream->isReadable() || ! $stream->isSeekable()) {
            throw new InvalidArgumentException('Message stream must be both readable and seekable');
        }

        $stream->rewind();

        list($method, $requestTarget, $version) = self::getRequestLine($stream);
        $uri = self::createUriFromRequestTarget($requestTarget);

        list($headers, $body) = self::splitStream($stream);

        return (new Request($uri, $method, $body, $headers))
            ->withProtocolVersion($version)
            ->withRequestTarget($requestTarget);
    }
public static function fromStream(StreamInterface $stream)
    {
        if (! $stream->isReadable() || ! $stream->isSeekable()) {
            throw new InvalidArgumentException('Message stream must be both readable and seekable');
        }

        $stream->rewind();

        list($method, $requestTarget, $version) = self::getRequestLine($stream);
        $uri = self::createUriFromRequestTarget($requestTarget);

        list($headers, $body) = self::splitStream($stream);

        return (new Request($uri, $method, $body, $headers))
            ->withProtocolVersion($version)
            ->withRequestTarget($requestTarget);
    }
public static function fromStream ( StreamInterface $ stream ) { if ( ! $ stream -> isReadable ( ) || ! $ stream -> isSeekable ( ) ) { throw new InvalidArgumentException ( 'Message stream must be both readable and seekable' ) ; } $ stream -> rewind ( ) ; list ( $ method , $ requestTarget , $ version ) = self :: getRequestLine ( $ stream ) ; $ uri = self :: createUriFromRequestTarget ( $ requestTarget ) ; list ( $ headers , $ body ) = self :: splitStream ( $ stream ) ; return ( new Request ( $ uri , $ method , $ body , $ headers ) ) -> withProtocolVersion ( $ version ) -> withRequestTarget ( $ requestTarget ) ; }
Deserialize a request stream to a request instance.

@param StreamInterface $stream
@return Request
@throws UnexpectedValueException when errors occur parsing the message.
Deserialize a request stream to a request instance .