WordPress\AiClientDependencies\Nyholm\Psr7
Uri::createUriString
Create a URI string from its various parts.
Method of the class: Uri{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = Uri::createUriString( $scheme, $authority, $path, $query, $fragment ): string;
- $scheme(string) (required)
- .
- $authority(string) (required)
- .
- $path(string) (required)
- .
- $query(string) (required)
- .
- $fragment(string) (required)
- .
Uri::createUriString() Uri::createUriString code WP 7.0
private static function createUriString(string $scheme, string $authority, string $path, string $query, string $fragment): string
{
$uri = '';
if ('' !== $scheme) {
$uri .= $scheme . ':';
}
if ('' !== $authority) {
$uri .= '//' . $authority;
}
if ('' !== $path) {
if ('/' !== $path[0]) {
if ('' !== $authority) {
// If the path is rootless and an authority is present, the path MUST be prefixed by "/"
$path = '/' . $path;
}
} elseif (isset($path[1]) && '/' === $path[1]) {
if ('' === $authority) {
// If the path is starting with more than one "/" and no authority is present, the
// starting slashes MUST be reduced to one.
$path = '/' . \ltrim($path, '/');
}
}
$uri .= $path;
}
if ('' !== $query) {
$uri .= '?' . $query;
}
if ('' !== $fragment) {
$uri .= '#' . $fragment;
}
return $uri;
}