You are here

function uri_for in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/functions.php \GuzzleHttp\Psr7\uri_for()

Returns a UriInterface for the given value.

This function accepts a string or {returns a UriInterface for the given value. If the value is already a `UriInterface`, it is returned as-is.

Parameters

string|UriInterface $uri:

Return value

UriInterface

Throws

\InvalidArgumentException

See also

Psr\Http\Message\UriInterface} and

File

vendor/guzzlehttp/psr7/src/functions.php, line 53

Namespace

GuzzleHttp\Psr7

Code

function uri_for($uri) {
  if ($uri instanceof UriInterface) {
    return $uri;
  }
  elseif (is_string($uri)) {
    return new Uri($uri);
  }
  throw new \InvalidArgumentException('URI must be a string or UriInterface');
}