You are here

function uri_for in Lockr 7.3

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 54

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');
}