You are here

private static function Uri::createUriString in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::createUriString()
  2. 8 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::createUriString()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::createUriString()

Create a URI string from its various parts

Parameters

string $scheme:

string $authority:

string $path:

string $query:

string $fragment:

Return value

string

1 call to Uri::createUriString()
Uri::__toString in vendor/zendframework/zend-diactoros/src/Uri.php
Return the string representation as a URI reference.

File

vendor/zendframework/zend-diactoros/src/Uri.php, line 466

Class

Uri
Implementation of Psr\Http\UriInterface.

Namespace

Zend\Diactoros

Code

private static function createUriString($scheme, $authority, $path, $query, $fragment) {
  $uri = '';
  if (!empty($scheme)) {
    $uri .= sprintf('%s://', $scheme);
  }
  if (!empty($authority)) {
    $uri .= $authority;
  }
  if ($path) {
    if (empty($path) || '/' !== substr($path, 0, 1)) {
      $path = '/' . $path;
    }
    $uri .= $path;
  }
  if ($query) {
    $uri .= sprintf('?%s', $query);
  }
  if ($fragment) {
    $uri .= sprintf('#%s', $fragment);
  }
  return $uri;
}