src/Viserio/Component/Http/Response/XmlResponse.php
private function createBody($text): StreamInterface
    {
        if ($text instanceof StreamInterface) {
            return $text;
        }

        if (! \is_string($text)) {
            throw new InvalidArgumentException(\sprintf(
                'Invalid content [%s] provided to %s',
                (\is_object($text) ? \get_class($text) : \gettype($text)),
                __CLASS__
            ));
        }

        $body = new Stream(\fopen('php://temp', 'w+b'));
        $body->write($text);
        $body->rewind();

        return $body;
    }
private function createBody($text): StreamInterface
    {
        if ($text instanceof StreamInterface) {
            return $text;
        }

        if (! \is_string($text)) {
            throw new InvalidArgumentException(\sprintf(
                'Invalid content [%s] provided to %s',
                (\is_object($text) ? \get_class($text) : \gettype($text)),
                __CLASS__
            ));
        }

        $body = new Stream(\fopen('php://temp', 'w+b'));
        $body->write($text);
        $body->rewind();

        return $body;
    }
Create the message body.

@param \Psr\Http\Message\StreamInterface|string $text

@throws \Viserio\Component\Contract\Http\Exception\InvalidArgumentException if $text is neither a string or stream

@return \Psr\Http\Message\StreamInterface