Urn
in package
implements
Conditionable, Stringable, JsonSerializable
Tags
Table of Contents
Interfaces
- Conditionable
- Stringable
- JsonSerializable
Constants
- REGEX_NID_SEQUENCE = '/^[a-z0-9]([a-z0-9-]{0,30})[a-z0-9]$/xi'
- RFC8141 namespace identifier regular expression.
- REGEXP_URN_PARTS = '/^ urn: (?<nid>[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?): # NID (?<nss>.*?) # NSS (?<frc>\?\+(?<rcomponent>.*?))? # r-component (?<fqc>\?\=(?<qcomponent>.*?))? # q-component (?:\#(?<fcomponent>.*))? # f-component $/xi'
- RFC8141 regular expression URN splitter.
Properties
- $fComponent : non-empty-string|null
- $nid : non-empty-string
- $nss : non-empty-string
- $qComponent : non-empty-string|null
- $rComponent : non-empty-string|null
- $uriString : non-empty-string
Methods
- __debugInfo() : UrnMap
- __serialize() : UrnSerialize
- __toString() : non-empty-string
- Returns the RFC8141 URN string representation.
- __unserialize() : void
- equals() : bool
- fromComponents() : self
- Create a new instance from a hash representation of the URI similar to PHP parse_url function result.
- fromRfc2141() : self
- fromString() : self
- getFComponent() : non-empty-string|null
- Returns the percent-encoded f-component string or null if it is not set.
- getNid() : non-empty-string
- Returns the NID.
- getNss() : non-empty-string
- Returns the percent-encoded NSS.
- getQComponent() : non-empty-string|null
- Returns the percent-encoded q-component string or null if it is not set.
- getRComponent() : non-empty-string|null
- Returns the percent-encoded r-component string or null if it is not set.
- hasFComponent() : bool
- hasOptionalComponent() : bool
- hasQComponent() : bool
- hasRComponent() : bool
- jsonSerialize() : non-empty-string
- Returns the RFC8141 URN string representation.
- new() : self
- normalize() : self
- parse() : Urn|null
- resolve() : UriInterface
- Returns the RFC3986 representation of the current URN.
- toComponents() : UrnMap
- toDisplayString() : string
- Returns the human-readable string representation of the URN as an IRI.
- toRfc2141() : non-empty-string
- Returns the RFC2141 URN string representation.
- toString() : non-empty-string
- Returns the RFC8141 URN string representation.
- when() : static
- Apply the callback if the given "condition" is (or resolves to) true.
- withFComponent() : self
- Return an instance with the specified f-component.
- withNid() : self
- Return an instance with the specified NID.
- withNss() : self
- Return an instance with the specified NSS.
- withQComponent() : self
- Return an instance with the specified q-component.
- withRComponent() : self
- Return an instance with the specified r-component.
- __construct() : mixed
- formatComponent() : string|null
- setUriString() : non-empty-string
Constants
REGEX_NID_SEQUENCE
RFC8141 namespace identifier regular expression.
private
string
REGEX_NID_SEQUENCE
= '/^[a-z0-9]([a-z0-9-]{0,30})[a-z0-9]$/xi'
Tags
REGEXP_URN_PARTS
RFC8141 regular expression URN splitter.
private
string
REGEXP_URN_PARTS
= '/^
urn:
(?<nid>[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?): # NID
(?<nss>.*?) # NSS
(?<frc>\?\+(?<rcomponent>.*?))? # r-component
(?<fqc>\?\=(?<qcomponent>.*?))? # q-component
(?:\#(?<fcomponent>.*))? # f-component
$/xi'
The regexp does not perform any look-ahead. Not all invalid URN are caught. Some post-regexp-validation checks are mandatory.
Tags
Properties
$fComponent read-only
private
non-empty-string|null
$fComponent
$nid read-only
private
non-empty-string
$nid
$nss read-only
private
non-empty-string
$nss
$qComponent read-only
private
non-empty-string|null
$qComponent
$rComponent read-only
private
non-empty-string|null
$rComponent
$uriString read-only
private
non-empty-string
$uriString
Methods
__debugInfo()
public
__debugInfo() : UrnMap
Return values
UrnMap__serialize()
public
__serialize() : UrnSerialize
Return values
UrnSerialize__toString()
Returns the RFC8141 URN string representation.
public
__toString() : non-empty-string
Tags
Return values
non-empty-string__unserialize()
public
__unserialize(UrnSerialize $data) : void
Parameters
- $data : UrnSerialize
Tags
equals()
public
equals(Urn|Uri|Url|Stringable|string $other[, UrnComparisonMode $urnComparisonMode = UrnComparisonMode::ExcludeComponents ]) : bool
Parameters
- $other : Urn|Uri|Url|Stringable|string
- $urnComparisonMode : UrnComparisonMode = UrnComparisonMode::ExcludeComponents
Return values
boolfromComponents()
Create a new instance from a hash representation of the URI similar to PHP parse_url function result.
public
static fromComponents([InputComponentMap $components = [] ]) : self
Parameters
- $components : InputComponentMap = []
-
a hash representation of the URI similar to PHP parse_url function result
Return values
selffromRfc2141()
public
static fromRfc2141(Stringable|string $nid, Stringable|string $nss) : self
Parameters
- $nid : Stringable|string
- $nss : Stringable|string
-
the percent-encoded NSS
Tags
Return values
selffromString()
public
static fromString(Uri|Url|Stringable|string $urn) : self
Parameters
- $urn : Uri|Url|Stringable|string
-
the percent-encoded URN
Tags
Return values
selfgetFComponent()
Returns the percent-encoded f-component string or null if it is not set.
public
getFComponent() : non-empty-string|null
Return values
non-empty-string|nullgetNid()
Returns the NID.
public
getNid() : non-empty-string
Return values
non-empty-stringgetNss()
Returns the percent-encoded NSS.
public
getNss() : non-empty-string
Return values
non-empty-stringgetQComponent()
Returns the percent-encoded q-component string or null if it is not set.
public
getQComponent() : non-empty-string|null
Return values
non-empty-string|nullgetRComponent()
Returns the percent-encoded r-component string or null if it is not set.
public
getRComponent() : non-empty-string|null
Return values
non-empty-string|nullhasFComponent()
public
hasFComponent() : bool
Return values
boolhasOptionalComponent()
public
hasOptionalComponent() : bool
Return values
boolhasQComponent()
public
hasQComponent() : bool
Return values
boolhasRComponent()
public
hasRComponent() : bool
Return values
booljsonSerialize()
Returns the RFC8141 URN string representation.
public
jsonSerialize() : non-empty-string
Tags
Return values
non-empty-stringnew()
public
static new(Uri|Url|Stringable|string $urn) : self
Parameters
- $urn : Uri|Url|Stringable|string
-
the percent-encoded URN
Tags
Return values
selfnormalize()
public
normalize() : self
Return values
selfparse()
public
static parse(Uri|Url|Stringable|string $urn) : Urn|null
Parameters
- $urn : Uri|Url|Stringable|string
-
the percent-encoded URN
Return values
Urn|nullresolve()
Returns the RFC3986 representation of the current URN.
public
resolve([UriTemplate|Template|string|null $template = null ]) : UriInterface
If a template URI is used the following variables as present {nid} for the namespace identifier {nss} for the namespace specific string {r_component} for the r-component without its delimiter {q_component} for the q-component without its delimiter {f_component} for the f-component without its delimiter
Parameters
- $template : UriTemplate|Template|string|null = null
Return values
UriInterfacetoComponents()
public
toComponents() : UrnMap
Return values
UrnMaptoDisplayString()
Returns the human-readable string representation of the URN as an IRI.
public
toDisplayString() : string
Tags
Return values
stringtoRfc2141()
Returns the RFC2141 URN string representation.
public
toRfc2141() : non-empty-string
Return values
non-empty-stringtoString()
Returns the RFC8141 URN string representation.
public
toString() : non-empty-string
Return values
non-empty-stringwhen()
Apply the callback if the given "condition" is (or resolves to) true.
public
when(callable|bool $condition, callable $onSuccess[, callable|null $onFail = null ]) : static
Parameters
- $condition : callable|bool
- $onSuccess : callable
- $onFail : callable|null = null
Return values
staticwithFComponent()
Return an instance with the specified f-component.
public
withFComponent(Stringable|string|null $component) : self
This method MUST retain the state of the current instance, and return an instance that contains the specified f-component.
The component is removed if the value is null.
Parameters
- $component : Stringable|string|null
Tags
Return values
selfwithNid()
Return an instance with the specified NID.
public
withNid(Stringable|string $nid) : self
This method MUST retain the state of the current instance, and return an instance that contains the specified NID.
Parameters
- $nid : Stringable|string
Tags
Return values
selfwithNss()
Return an instance with the specified NSS.
public
withNss(Stringable|string $nss) : self
This method MUST retain the state of the current instance, and return an instance that contains the specified NSS.
Parameters
- $nss : Stringable|string
Tags
Return values
selfwithQComponent()
Return an instance with the specified q-component.
public
withQComponent(Stringable|string|null $component) : self
This method MUST retain the state of the current instance, and return an instance that contains the specified q-component.
The component is removed if the value is null.
Parameters
- $component : Stringable|string|null
Tags
Return values
selfwithRComponent()
Return an instance with the specified r-component.
public
withRComponent(Stringable|string|null $component) : self
This method MUST retain the state of the current instance, and return an instance that contains the specified r-component.
The component is removed if the value is null.
Parameters
- $component : Stringable|string|null
Tags
Return values
self__construct()
private
__construct(string $nid, string $nss[, string|null $rComponent = null ][, string|null $qComponent = null ][, string|null $fComponent = null ]) : mixed
Parameters
- $nid : string
- $nss : string
-
the percent-encoded NSS
- $rComponent : string|null = null
-
the percent-encoded r-component
- $qComponent : string|null = null
-
the percent-encoded q-component
- $fComponent : string|null = null
-
the percent-encoded f-component
Tags
formatComponent()
private
static formatComponent(string|null $component) : string|null
Parameters
- $component : string|null
Return values
string|nullsetUriString()
private
setUriString() : non-empty-string