Documentation

UriNormalizer
in package

A simply utility class normalizing the URIs

Tags
author

zozlak

Table of Contents

Properties

$cache  : CacheInterface
$client  : ClientInterface
$dataFactory  : DataFactoryInterface
$idTmpl  : PredicateTemplate
$mappings  : array<string|int, UriNormalizerRule>
$obj  : self

Methods

__construct()  : mixed
fetch()  : DatasetNode
Fetches RDF metadata for a given URI.
gFetch()  : DatasetNode
A static version of the fetch() method.
gNormalize()  : string
A static version of the normalize() method.
gNormalizeMeta()  : void
A static version of the normalizeMeta() method.
gNormalizeNN()  : NamedNodeInterface
A static version of the normalizeNN() method.
gResolve()  : RequestInterface
A static version of the resolve() method.
init()  : void
Initializes a global singleton instance of the UriNormalizer.
normalize()  : string
Returns a normalized URI as string.
normalizeMeta()  : void
Performs id URI normalization on all id properties of a given metadata resource object.
normalizeNN()  : NamedNodeInterface
Returns a normalized URI as a NamedNodeInterface object.
resolve()  : Request
Resolves a given URI to a PSR-7 request fetching its RDF metadata.
fetchUrl()  : ResponseInterface
setCache()  : void

Properties

Methods

__construct()

public __construct([array<string|int, UriNormalizerRule|array<string, string>|stdClass>|null $mappings = null ][, NamedNodeInterface|string $idProp = '' ][, ClientInterface|null $client = null ][, CacheInterface|null $cache = null ][, DataFactoryInterface $dataFactory = null ]) : mixed
Parameters
$mappings : array<string|int, UriNormalizerRule|array<string, string>|stdClass>|null = null

a set of normalization rules to be used. If they are not UriNormRule objects, an attempt to cast them is made with the UriNormRule::factory(). If null is passed, rules provided by the UriNormRules::getRules() class are used.

$idProp : NamedNodeInterface|string = ''

a default RDF property to be used by the normalizeMeta() method

$client : ClientInterface|null = null

a PSR-18 HTTP client to be used to resolve URIs. If not provided, a new instance of a \GuzzleHttp\Client is used.

$cache : CacheInterface|null = null

instance of a PSR-16 compatible cache object for caching normalize()/resolve()/normalize() results

$dataFactory : DataFactoryInterface = null

factory class to be used to create RDF terms. If not provided, a quickRdf\DataFactory from the sweetrdf/quick-rdf library is used.

fetch()

Fetches RDF metadata for a given URI.

public fetch(NamedNodeInterface|string $uri) : DatasetNode

Throws UriNormalizerException when the retrieval fails.

Parameters
$uri : NamedNodeInterface|string
Tags
throws
UriNormalizerException
Return values
DatasetNode

gFetch()

A static version of the fetch() method.

public static gFetch(NamedNodeInterface|string $uri) : DatasetNode

Call UriNormalizer::init() before first use.

Parameters
$uri : NamedNodeInterface|string
Tags
see
UriNormalizer::fetch()
Return values
DatasetNode

gNormalize()

A static version of the normalize() method.

public static gNormalize(NamedNodeInterface|string $uri[, bool $requireMatch = true ]) : string

Call UriNormalizer::init() before first use.

Parameters
$uri : NamedNodeInterface|string
$requireMatch : bool = true
Tags
see
UriNormalizer::normalize()
Return values
string

gNormalizeMeta()

A static version of the normalizeMeta() method.

public static gNormalizeMeta(DatasetInterface $res[, NamedNodeInterface|string $idProp = '' ][, bool $requireMatch = true ]) : void

Call UriNormalizer::init() before first use.

Parameters
$res : DatasetInterface

metadata to be processed

$idProp : NamedNodeInterface|string = ''

id property URI (if not provided, value passed to the UriNormalizer::init() is used)

$requireMatch : bool = true

should an exception be rised if the $uri matches no rule

Tags
see
UriNormalizer::normalizeMeta()

gNormalizeNN()

A static version of the normalizeNN() method.

public static gNormalizeNN(NamedNodeInterface|string $uri[, bool $requireMatch = true ]) : NamedNodeInterface

Call UriNormalizer::init() before first use.

Parameters
$uri : NamedNodeInterface|string
$requireMatch : bool = true
Tags
see
UriNormalizer::normalize()
Return values
NamedNodeInterface

gResolve()

A static version of the resolve() method.

public static gResolve(NamedNodeInterface|string $uri) : RequestInterface

Call UriNormalizer::init() before first use.

Parameters
$uri : NamedNodeInterface|string
Tags
see
UriNormalizer::resolve()
Return values
RequestInterface

init()

Initializes a global singleton instance of the UriNormalizer.

public static init([array<string|int, UriNormalizerRule|array<string, string>|stdClass>|null $mappings = null ][, string $idProp = '' ][, ClientInterface|null $client = null ][, CacheInterface|null $cache = null ][, DataFactoryInterface $dataFactory = null ]) : void
Parameters
$mappings : array<string|int, UriNormalizerRule|array<string, string>|stdClass>|null = null

a set of normalization rules to be used. If they are not UriNormalizerRule objects, an attempt to cast them is made with the UriNormalizerRule::factory(). If null is passed, rules provided by the UriNormRules::getRules() class are used.

$idProp : string = ''

a default RDF property to be used by the normalizeMeta() method

$client : ClientInterface|null = null

a PSR-18 HTTP client to be used to resolve URIs. If not provided, a new instance of a \GuzzleHttp\Client is used.

$cache : CacheInterface|null = null

instance of a PSR-16 compatible cache object for caching normalize()/resolve()/normalize() results

$dataFactory : DataFactoryInterface = null

factory class to be used to create RDF terms. If not provided, a quickRdf\DataFactory from the sweetrdf/quick-rdf library is used.

Tags
see
UriNormalizer::__construct()

normalize()

Returns a normalized URI as string.

public normalize(NamedNodeInterface|string $uri[, bool $requireMatch = true ]) : string
Parameters
$uri : NamedNodeInterface|string

URI to be normalized

$requireMatch : bool = true

should an exception be rised if the $uri matches no rule

Tags
throws
UriNormalizerException
Return values
string

normalizeMeta()

Performs id URI normalization on all id properties of a given metadata resource object.

public normalizeMeta(DatasetInterface $res[, NamedNodeInterface|string $idProp = '' ][, bool $requireMatch = true ]) : void

The normalization is performed in-place, therefore the return type is void.

Parameters
$res : DatasetInterface

metadata to be processed

$idProp : NamedNodeInterface|string = ''

id property URI (if not provided, value passed to the object constructor is used)

$requireMatch : bool = true

should an exception be rised if the $uri matches no rule

Tags
throws
UriNormalizerException

normalizeNN()

Returns a normalized URI as a NamedNodeInterface object.

public normalizeNN(NamedNodeInterface|string $uri[, bool $requireMatch = true ]) : NamedNodeInterface
Parameters
$uri : NamedNodeInterface|string

URI to be normalized

$requireMatch : bool = true

should an exception be rised if the $uri matches no rule

Tags
throws
UriNormalizerException
Return values
NamedNodeInterface

resolve()

Resolves a given URI to a PSR-7 request fetching its RDF metadata.

public resolve(NamedNodeInterface|string $uri) : Request

Throws the UriNormalizerException if the resolving fails.

Parameters
$uri : NamedNodeInterface|string
Tags
throws
UriNormalizerException
Return values
Request

setCache()

private setCache(string $key1, string $key2, mixed $value) : void
Parameters
$key1 : string
$key2 : string
$value : mixed

        
On this page

Search results