Documentation

RdfNamespace
in package
implements RdfNamespaceInterface

AbstractYes

Provides an implementation of rdfInterface\RdfNamespace.

The class is abstract as it depends on the rdfInterface\NamedNode implementation which is not provided in this library.

It can be reused by deriving a class from it and providing an implementation of the getNamedNode() method (which should be just a one-liner).

Tags
author

zozlak

Table of Contents

Interfaces

RdfNamespaceInterface

Properties

$n  : int
$namespaces  : array<string, string>

Methods

add()  : string
Registers a given URL prefix.
expand()  : NamedNodeInterface
Expands a shortened IRI to a NamedNode.
get()  : string
Returns a IRI prefix for a given short name.
getAll()  : array<string, string>
Returns associative array of all registered namespaces with array keys being namespace short names and array values containing URL prefixes.
remove()  : void
Drops a given short name and IRI prefix associated with it.
shorten()  : string
Shortens provided NamedNode IRI.
getNamedNode()  : NamedNodeInterface

Properties

$namespaces

private array<string, string> $namespaces = []

Methods

add()

Registers a given URL prefix.

public add(string $iriPrefix[, string|null $shortName = null ]) : string
Parameters
$iriPrefix : string
$shortName : string|null = null

Short name to register the IRI prefix under. If null or empty, the short name is automatically generated.

Return values
string

The short name under which the URL prefix was registered.

expand()

Expands a shortened IRI to a NamedNode.

public expand(string $shortIri) : NamedNodeInterface

Throws an error if the short name used in the shortened IRI is unknown or when the $shortIri is not a shortened IRI.

Parameters
$shortIri : string
Return values
NamedNodeInterface

get()

Returns a IRI prefix for a given short name.

public get(string $shortName) : string

Throws an exception if a given short name isn't registered.

Parameters
$shortName : string
Return values
string

getAll()

Returns associative array of all registered namespaces with array keys being namespace short names and array values containing URL prefixes.

public getAll() : array<string, string>
Return values
array<string, string>

remove()

Drops a given short name and IRI prefix associated with it.

public remove(string $shortName) : void
Parameters
$shortName : string

shorten()

Shortens provided NamedNode IRI.

public shorten(NamedNodeInterface $iri, bool $create) : string

If corresponding IRI prefix is not registered yet, the behavior depends on the $create parameter value. If it's true, a new short name is registered automatically. Otherwise an expception is thrown.

Parameters
$iri : NamedNodeInterface
$create : bool

Should a new short name be registered for the IRI prefix if there is no matching one?

Return values
string

        
On this page

Search results