Open Journal Systems  3.3.0
GuzzleHttp\Psr7\UriResolver Class Reference

Static Public Member Functions

static relativize (UriInterface $base, UriInterface $target)
 
static removeDotSegments ($path)
 
static resolve (UriInterface $base, UriInterface $rel)
 

Detailed Description

Resolves a URI reference in the context of a base URI and the opposite way.

Author
Tobias Schultze

https://tools.ietf.org/html/rfc3986#section-5

Definition at line 13 of file UriResolver.php.

Member Function Documentation

◆ relativize()

static GuzzleHttp\Psr7\UriResolver::relativize ( UriInterface  $base,
UriInterface  $target 
)
static

Returns the target URI as a relative reference from the base URI.

This method is the counterpart to resolve():

(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))

One use-case is to use the current request URI as base URI and then generate relative links in your documents to reduce the document size or offer self-contained downloadable document archives.

$base = new Uri('http://example.com/a/b/'); echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.

This method also accepts a target that is already relative and will try to relativize it further. Only a relative-path reference will be returned as-is.

echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well

Parameters
UriInterface$baseBase URI
UriInterface$targetTarget URI
Returns
UriInterface The relative URI reference

Definition at line 137 of file UriResolver.php.

References Psr\Http\Message\UriInterface\getAuthority(), Psr\Http\Message\UriInterface\getPath(), Psr\Http\Message\UriInterface\getQuery(), Psr\Http\Message\UriInterface\getScheme(), GuzzleHttp\Psr7\Uri\isRelativePathReference(), and Psr\Http\Message\UriInterface\withScheme().

◆ removeDotSegments()

static GuzzleHttp\Psr7\UriResolver::removeDotSegments (   $path)
static

Removes dot segments from a path and returns the new path.

Parameters
string$path
Returns
string http://tools.ietf.org/html/rfc3986#section-5.2.4

Definition at line 23 of file UriResolver.php.

Referenced by GuzzleHttp\Psr7\UriNormalizer\normalize(), GuzzleHttp\Psr7\Uri\removeDotSegments(), and GuzzleHttp\Psr7\UriResolver\resolve().

◆ resolve()


The documentation for this class was generated from the following file: