private function getStream($stream)
    {
        if ($stream === 'php://input') {
            return new PhpInputStream();
        }

        if (! is_string($stream) && ! is_resource($stream) && ! $stream instanceof StreamInterface) {
            throw new InvalidArgumentException(
                'Stream must be a string stream resource identifier, '
                . 'an actual stream resource, '
                . 'or a Psr\Http\Message\StreamInterface implementation'
            );
        }

        if (! $stream instanceof StreamInterface) {
            return new Stream($stream, 'r');
        }

        return $stream;
    }