BaseUri
in package
implements
Stringable, JsonSerializable, UriAccess
since version 7.6.0
Tags
Table of Contents
Interfaces
- Stringable
- JsonSerializable
- UriAccess
Constants
- DOT_SEGMENTS = ['.' => 1, '..' => 1]
- WHATWG_SPECIAL_SCHEMES = ['ftp' => 1, 'http' => 1, 'https' => 1, 'ws' => 1, 'wss' => 1]
Properties
- $nullValue : string|null
- $origin : UriInterface|UriInterface|null
- $uri : UriInterface|UriInterface
- $uriFactory : UriFactoryInterface|null
Methods
- __toString() : string
- from() : static
- getUri() : UriInterface|UriInterface
- getUriString() : string
- Returns the RFC3986 string representation of the complete URI.
- hasIdn() : bool
- Tells whether the URI contains an Internationalized Domain Name (IDN).
- hasIPv4() : bool
- Tells whether the URI contains an IPv4 regardless if it is mapped or native.
- isAbsolute() : bool
- Tells whether the URI is absolute.
- isAbsolutePath() : bool
- Tells whether the URI is an absolute path.
- isCrossOrigin() : bool
- Tells whether two URI do not share the same origin.
- isLocalFile() : bool
- Tells whether the `file` scheme base URI represents a local file.
- isNetworkPath() : bool
- Tells whether the URI is a network path.
- isOpaque() : bool
- Tells whether the URI is opaque or not.
- isRelativePath() : bool
- Tells whether the URI is a relative path.
- isSameDocument() : bool
- Tells whether both URI refers to the same document.
- jsonSerialize() : string
- origin() : self|null
- relativize() : static
- Relativize a URI according to a base URI.
- resolve() : static
- Resolves a URI against a base URI using RFC3986 rules.
- toRfc8089() : string|null
- Returns a string representation of a File URI according to RFC8089.
- unixPath() : string|null
- Returns the Unix filesystem path.
- windowsPath() : string|null
- Returns the Windows filesystem path.
- withoutUriFactory() : static
- withUriFactory() : static
- __construct() : mixed
- canNotBeRelativize() : bool
- Tells whether the submitted URI object can be relativized.
- componentEquals() : bool
- Tells whether the component value from both URI object equals.
- computeOrigin() : UriInterface|UriInterface|null
- filterUri() : UriInterface|UriInterface
- Input URI normalization to allow Stringable and string URI.
- formatHost() : UriInterface|UriInterface
- Filter the URI object.
- formatPath() : string
- Formatting the path to keep a valid URI.
- formatPathWithEmptyBaseQuery() : string
- Formatting the path to keep a resolvable URI.
- getSegments() : array<string|int, string>
- returns the path segments.
- normalize() : string
- Normalizes a URI for comparison; this URI string representation is not suitable for usage as per RFC guidelines.
- relativizePath() : string
- Relatives the URI for an authority-less target URI.
- removeDotSegments() : string
- Remove dot segments from the URI path as per RFC specification.
- resolvePathAndQuery() : array{0: string, 1: string|null}
- Resolves an URI path and query component.
- normalizedUri() : Uri
Constants
DOT_SEGMENTS
protected
final array<string, int>
DOT_SEGMENTS
= ['.' => 1, '..' => 1]
WHATWG_SPECIAL_SCHEMES
protected
final array<string, int>
WHATWG_SPECIAL_SCHEMES
= ['ftp' => 1, 'http' => 1, 'https' => 1, 'ws' => 1, 'wss' => 1]
Properties
$nullValue read-only
protected
string|null
$nullValue
$origin read-only
protected
UriInterface|UriInterface|null
$origin
$uri read-only
protected
UriInterface|UriInterface
$uri
$uriFactory read-only
protected
UriFactoryInterface|null
$uriFactory
Methods
__toString()
public
__toString() : string
Return values
stringfrom()
public
static from(Stringable|string $uri[, UriFactoryInterface|null $uriFactory = null ]) : static
Parameters
- $uri : Stringable|string
- $uriFactory : UriFactoryInterface|null = null
Return values
staticgetUri()
public
getUri() : UriInterface|UriInterface
Return values
UriInterface|UriInterfacegetUriString()
Returns the RFC3986 string representation of the complete URI.
public
getUriString() : string
Return values
stringhasIdn()
Tells whether the URI contains an Internationalized Domain Name (IDN).
public
hasIdn() : bool
Return values
boolhasIPv4()
Tells whether the URI contains an IPv4 regardless if it is mapped or native.
public
hasIPv4() : bool
Return values
boolisAbsolute()
Tells whether the URI is absolute.
public
isAbsolute() : bool
Return values
boolisAbsolutePath()
Tells whether the URI is an absolute path.
public
isAbsolutePath() : bool
Return values
boolisCrossOrigin()
Tells whether two URI do not share the same origin.
public
isCrossOrigin(Stringable|string $uri) : bool
Parameters
- $uri : Stringable|string
Return values
boolisLocalFile()
Tells whether the `file` scheme base URI represents a local file.
public
isLocalFile() : bool
Return values
boolisNetworkPath()
Tells whether the URI is a network path.
public
isNetworkPath() : bool
Return values
boolisOpaque()
Tells whether the URI is opaque or not.
public
isOpaque() : bool
A URI is opaque if and only if it is absolute and does not have an authority path.
Return values
boolisRelativePath()
Tells whether the URI is a relative path.
public
isRelativePath() : bool
Return values
boolisSameDocument()
Tells whether both URI refers to the same document.
public
isSameDocument(Stringable|string $uri) : bool
Parameters
- $uri : Stringable|string
Return values
booljsonSerialize()
public
jsonSerialize() : string
Return values
stringorigin()
public
origin() : self|null
Return values
self|nullrelativize()
Relativize a URI according to a base URI.
public
relativize(Stringable|string $uri) : static
This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.
This method MUST be transparent when dealing with error and exceptions. It MUST not alter of silence them apart from validating its own parameters.
Parameters
- $uri : Stringable|string
Return values
staticresolve()
Resolves a URI against a base URI using RFC3986 rules.
public
resolve(Stringable|string $uri) : static
This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.
This method MUST be transparent when dealing with error and exceptions. It MUST not alter or silence them apart from validating its own parameters.
Parameters
- $uri : Stringable|string
Return values
statictoRfc8089()
Returns a string representation of a File URI according to RFC8089.
public
toRfc8089() : string|null
The method will return null if the URI scheme is not the file scheme
Return values
string|nullunixPath()
Returns the Unix filesystem path.
public
unixPath() : string|null
The method will return null if a scheme is present and is not the file scheme
Return values
string|nullwindowsPath()
Returns the Windows filesystem path.
public
windowsPath() : string|null
The method will return null if a scheme is present and is not the file scheme
Return values
string|nullwithoutUriFactory()
public
withoutUriFactory() : static
Return values
staticwithUriFactory()
public
withUriFactory(UriFactoryInterface $uriFactory) : static
Parameters
- $uriFactory : UriFactoryInterface
Return values
static__construct()
protected
final __construct(UriInterface|UriInterface $uri, UriFactoryInterface|null $uriFactory) : mixed
Parameters
- $uri : UriInterface|UriInterface
- $uriFactory : UriFactoryInterface|null
-
Deprecated, will be removed in the next major release
canNotBeRelativize()
Tells whether the submitted URI object can be relativized.
protected
final canNotBeRelativize(UriInterface|UriInterface $uri) : bool
Parameters
- $uri : UriInterface|UriInterface
Return values
boolcomponentEquals()
Tells whether the component value from both URI object equals.
protected
final componentEquals(string $property, UriInterface|UriInterface $uri) : bool
Parameters
- $property : string
- $uri : UriInterface|UriInterface
Tags
Return values
boolcomputeOrigin()
protected
final computeOrigin(UriInterface|UriInterface $uri, string|null $nullValue) : UriInterface|UriInterface|null
Parameters
- $uri : UriInterface|UriInterface
- $nullValue : string|null
Return values
UriInterface|UriInterface|nullfilterUri()
Input URI normalization to allow Stringable and string URI.
protected
final static filterUri(Stringable|string $uri[, UriFactoryInterface|null $uriFactory = null ]) : UriInterface|UriInterface
Parameters
- $uri : Stringable|string
- $uriFactory : UriFactoryInterface|null = null
Return values
UriInterface|UriInterfaceformatHost()
Filter the URI object.
protected
final static formatHost(UriInterface|UriInterface $uri) : UriInterface|UriInterface
Parameters
- $uri : UriInterface|UriInterface
Return values
UriInterface|UriInterfaceformatPath()
Formatting the path to keep a valid URI.
protected
final static formatPath(string $path, string $basePath) : string
Parameters
- $path : string
- $basePath : string
Return values
stringformatPathWithEmptyBaseQuery()
Formatting the path to keep a resolvable URI.
protected
final static formatPathWithEmptyBaseQuery(string $path) : string
Parameters
- $path : string
Return values
stringgetSegments()
returns the path segments.
protected
final static getSegments(string $path) : array<string|int, string>
Parameters
- $path : string
Return values
array<string|int, string>normalize()
Normalizes a URI for comparison; this URI string representation is not suitable for usage as per RFC guidelines.
protected
final normalize(UriInterface|UriInterface $uri) : string
since version 7.6.0
no longer used by the isSameDocument method
Parameters
- $uri : UriInterface|UriInterface
Tags
Return values
stringrelativizePath()
Relatives the URI for an authority-less target URI.
protected
final static relativizePath(string $path, string $basePath) : string
Parameters
- $path : string
- $basePath : string
Return values
stringremoveDotSegments()
Remove dot segments from the URI path as per RFC specification.
protected
final removeDotSegments(string $path) : string
since version 7.6.0
no longer used by the isSameDocument method
Parameters
- $path : string
Tags
Return values
stringresolvePathAndQuery()
Resolves an URI path and query component.
protected
final resolvePathAndQuery(UriInterface|UriInterface $uri) : array{0: string, 1: string|null}
since version 7.6.0
no longer used by the isSameDocument method
Parameters
- $uri : UriInterface|UriInterface
Tags
Return values
array{0: string, 1: string|null}normalizedUri()
private
static normalizedUri(Stringable|string $uri) : Uri
Parameters
- $uri : Stringable|string