/**
* Creates a PHP stream resource from a ResponseInterface.
*
* @return resource
*/
public static function createResource(ResponseInterface
$response, HttpClientInterface
$client = null
) { if ($response instanceof StreamableInterface
) { $stack =
debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 2
);
if ($response !== ($stack[1
]['object'
] ?? null
)) { return $response->
toStream(false
);
} } if (null ===
$client && !
method_exists($response, 'stream'
)) { throw new \
InvalidArgumentException(sprintf('Providing a client to "%s()" is required when the response doesn\'t have any "stream()" method.', __CLASS__
));
} static $registered = false;
if (!
$registered =
$registered ||
stream_wrapper_register(strtr(__CLASS__, '\\', '-'
), __CLASS__
)) { throw new \
RuntimeException(error_get_last()['message'
] ?? 'Registering the "symfony" stream wrapper failed.'
);
}