Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
GuzzleHttp\Psr7\UriResolver Class Reference

Static Public Member Functions

static relativize (UriInterface $base, UriInterface $target)
 Returns the target URI as a relative reference from the base URI.
 
static removeDotSegments (string $path)
 Removes dot segments from a path and returns the new path.
 
static resolve (UriInterface $base, UriInterface $rel)
 Converts the relative URI into a new URI that is resolved against the base URI.
 

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

◆ removeDotSegments()

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

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

@externalurl http://tools.ietf.org/html/rfc3986#section-5.2.4

◆ resolve()

static GuzzleHttp\Psr7\UriResolver::resolve ( UriInterface $base,
UriInterface $rel )
static

Converts the relative URI into a new URI that is resolved against the base URI.

@externalurl http://tools.ietf.org/html/rfc3986#section-5.2


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