Documentation

Ontology
in package

Provides an API for the ARCHE oontology.

Maps the RDF ontology structure into the object model.

Tags
author

zozlak

Table of Contents

Constants

VOCABSVALUE_ALL  = 255
VOCABSVALUE_ALTLABEL  = 8
VOCABSVALUE_ID  = 1
VOCABSVALUE_NOTATION  = 2
VOCABSVALUE_PREFLABEL  = 4

Properties

$classes  : array<string|int, ClassDesc>
$classesRev  : array<string, array<string|int, ClassDesc>>
$distinctProperties  : array<string, PropertyDesc>
$pdo  : PDO
$properties  : array<string, PropertyDesc>
$repo  : Repo
$restrictions  : array<string, RestrictionDesc>
$schema  : Schema
$vocabsValueProperties  : array<string, int>

Methods

checkVocabularyValue()  : string|false
Checks if a given value exists in a given vocabulary.
factoryCache()  : self
factoryDb()  : self
factoryRest()  : self
getChildClasses()  : array<string|int, ClassDesc>
Returns all classes inheriting from a given one.
getClass()  : ClassDesc|null
Returns class description.
getClasses()  : array<string|int, ClassDesc>
Returns all classes known in the ontology.
getNamespace()  : string
getNamespaceClasses()  : array<string, ClassDesc>
Returns all classes in the given ontology namespace as an associative array with keys being class URIs in the ontology namespace.
getProperties()  : array<string|int, PropertyDesc>
Returns all properties defined in the ontology.
getProperty()  : PropertyDesc|null
Returns a given property description for a given set of RDF classes or an RDF resource (in the latter case classes list is extracted from the resource).
getVocabularyValue()  : SkosConceptDesc|null
Fetches SkosConceptDesc object desribing a vocabulary value.
getVocabularyValues()  : array<string|int, SkosConceptDesc>
Fetches an array of SkosConceptDesc objects desribing vocabulary values.
isA()  : bool
Checks if a given RDF resource is of a given class taking into account ontology class inheritance.
saveCache()  : void
buildClassesRevIndex()  : void
checkVocabularyValueDb()  : string|false
checkVocabularyValueRest()  : string|false
fetchVocabularyValuesDb()  : array<string|int, SkosConceptDesc>
Fetches information about SKOS concepts and formats them as SkosConceptDesc objects.
fetchVocabularyValuesRest()  : array<string|int, SkosConceptDesc>
Fetches information about SKOS concepts and formats them as SkosConceptDesc objects.
loadClassesDb()  : void
loadClassRest()  : void
loadPropertiesDb()  : void
loadPropertyCommon()  : void
loadPropertyRest()  : void
loadRest()  : void
loadRestrictionCommon()  : void
loadRestrictionRest()  : void
loadRestrictionsDb()  : void
preprocess()  : void
Combines class, property and restriction information
resolveParents()  : void

Constants

VOCABSVALUE_ALL

public mixed VOCABSVALUE_ALL = 255

VOCABSVALUE_ALTLABEL

public mixed VOCABSVALUE_ALTLABEL = 8

VOCABSVALUE_ID

public mixed VOCABSVALUE_ID = 1

VOCABSVALUE_NOTATION

public mixed VOCABSVALUE_NOTATION = 2

VOCABSVALUE_PREFLABEL

public mixed VOCABSVALUE_PREFLABEL = 4

Properties

$vocabsValueProperties

private static array<string, int> $vocabsValueProperties = [\zozlak\RdfConstants::SKOS_NOTATION => self::VOCABSVALUE_NOTATION, \zozlak\RdfConstants::SKOS_PREF_LABEL => self::VOCABSVALUE_PREFLABEL, \zozlak\RdfConstants::SKOS_ALT_LABEL => self::VOCABSVALUE_ALTLABEL]

Methods

checkVocabularyValue()

Checks if a given value exists in a given vocabulary.

public checkVocabularyValue(string $vocabularyUrl, string $value[, int $searchIn = self::VOCABSVALUE_ID ]) : string|false
Parameters
$vocabularyUrl : string
$value : string
$searchIn : int = self::VOCABSVALUE_ID

combination of Ontology::VOCABSVALUE_* flags indicating where to search for the $value (in a concept URI/ID, skos:notation, skos:prefLabel, etc.)

Return values
string|false

a vocabulary value identifier or false if $value is invalid

factoryCache()

public static factoryCache(string $cachePath) : self
Parameters
$cachePath : string
Return values
self

factoryDb()

public static factoryDb(PDO $pdo, Schema|stdClass $schema[, string|null $cache = null ][,  $cacheTtl = 600 ]) : self
Parameters
$pdo : PDO
$schema : Schema|stdClass
$cache : string|null = null

File storing ontology cache. If empty or null, cache isn't used.

$cacheTtl : = 600

time in seconds for which the cache file is considered valid. After that time (or when the cache file doesn't exist) the cache file is regenerated.

Return values
self

factoryRest()

public static factoryRest(string $url[, string|null $cache = null ][, int $cacheTtl = 600 ]) : self
Parameters
$url : string
$cache : string|null = null
$cacheTtl : int = 600
Return values
self

getChildClasses()

Returns all classes inheriting from a given one.

public getChildClasses(string|NamedNodeInterface|ClassDesc $class) : array<string|int, ClassDesc>
Parameters
$class : string|NamedNodeInterface|ClassDesc
Return values
array<string|int, ClassDesc>

getClass()

Returns class description.

public getClass(string|NamedNodeInterface $class) : ClassDesc|null
Parameters
$class : string|NamedNodeInterface

class name URI

Return values
ClassDesc|null

getClasses()

Returns all classes known in the ontology.

public getClasses() : array<string|int, ClassDesc>
Return values
array<string|int, ClassDesc>

getNamespace()

public getNamespace() : string
Return values
string

getNamespaceClasses()

Returns all classes in the given ontology namespace as an associative array with keys being class URIs in the ontology namespace.

public getNamespaceClasses() : array<string, ClassDesc>
Return values
array<string, ClassDesc>

getProperties()

Returns all properties defined in the ontology.

public getProperties() : array<string|int, PropertyDesc>

Property defintions read that way lack cardinality info as the cardinality constraints are defined on the level of property and class.

Return values
array<string|int, PropertyDesc>

getProperty()

Returns a given property description for a given set of RDF classes or an RDF resource (in the latter case classes list is extracted from the resource).

public getProperty(DatasetNodeInterface|array<string|int, string>|string|null $resClassOrClassArray, string|NamedNodeInterface $property) : PropertyDesc|null

If property domain matches many classes, a description for first encountered class is returned (property cardinality and range may vary between classes).

If no classes/RDF resource is provided all known classes are searched and a first encounterred match is returned (property cardinality and range may vary between classes).

Parameters
$resClassOrClassArray : DatasetNodeInterface|array<string|int, string>|string|null

an RDF resource or an array of RDF class URIs or an RDF class URI

$property : string|NamedNodeInterface

property URI

Return values
PropertyDesc|null

getVocabularyValue()

Fetches SkosConceptDesc object desribing a vocabulary value.

public getVocabularyValue(string $vocabularyUrl, string $value[, int $searchIn = self::VOCABSVALUE_ID ]) : SkosConceptDesc|null
Parameters
$vocabularyUrl : string
$value : string
$searchIn : int = self::VOCABSVALUE_ID

combination of Ontology::VOCABSVALUE_* flags indicating where to search for the $value (in a concept URI/ID, skos:notation, skos:prefLabel, etc.)

Return values
SkosConceptDesc|null

getVocabularyValues()

Fetches an array of SkosConceptDesc objects desribing vocabulary values.

public getVocabularyValues(string $vocabularyUrl) : array<string|int, SkosConceptDesc>
Parameters
$vocabularyUrl : string
Return values
array<string|int, SkosConceptDesc>

isA()

Checks if a given RDF resource is of a given class taking into account ontology class inheritance.

public isA(DatasetNodeInterface|array<string|int, string>|string $resClassOrClassArray, string|NamedNodeInterface $class) : bool
Parameters
$resClassOrClassArray : DatasetNodeInterface|array<string|int, string>|string
$class : string|NamedNodeInterface
Return values
bool

saveCache()

public saveCache(string $path) : void
Parameters
$path : string

buildClassesRevIndex()

private buildClassesRevIndex() : void

checkVocabularyValueDb()

private checkVocabularyValueDb(string $vocabularyUrl, string $value[, int $searchIn = self::VOCABSVALUE_ID ]) : string|false
Parameters
$vocabularyUrl : string
$value : string
$searchIn : int = self::VOCABSVALUE_ID
Return values
string|false

checkVocabularyValueRest()

private checkVocabularyValueRest(string $vocabularyUrl, string $value[, int $searchIn = self::VOCABSVALUE_ID ]) : string|false
Parameters
$vocabularyUrl : string
$value : string
$searchIn : int = self::VOCABSVALUE_ID
Return values
string|false

fetchVocabularyValuesDb()

Fetches information about SKOS concepts and formats them as SkosConceptDesc objects.

private fetchVocabularyValuesDb(string $valuesQuery, array<string|int, mixed> $valuesParam) : array<string|int, SkosConceptDesc>
Parameters
$valuesQuery : string
$valuesParam : array<string|int, mixed>
Return values
array<string|int, SkosConceptDesc>

fetchVocabularyValuesRest()

Fetches information about SKOS concepts and formats them as SkosConceptDesc objects.

private fetchVocabularyValuesRest(string $vocabularyUrl[, string|null $conceptUri = null ]) : array<string|int, SkosConceptDesc>
Parameters
$vocabularyUrl : string
$conceptUri : string|null = null
Return values
array<string|int, SkosConceptDesc>

loadClassesDb()

private loadClassesDb() : void

loadClassRest()

private loadClassRest(object $data, string $nmsp, string $baseUrl) : void
Parameters
$data : object
$nmsp : string
$baseUrl : string

loadPropertiesDb()

private loadPropertiesDb() : void

loadPropertyRest()

private loadPropertyRest(object $data, string $nmsp) : void
Parameters
$data : object
$nmsp : string

loadRestrictionRest()

private loadRestrictionRest(object $data, string $nmsp) : void
Parameters
$data : object
$nmsp : string

loadRestrictionsDb()

private loadRestrictionsDb() : void

preprocess()

Combines class, property and restriction information

private preprocess() : void

resolveParents()

private resolveParents(BaseDesc $obj, string $prop, array<string|int, object> $parents, SplObjectStorage<object, null> $visited) : void
Parameters
$obj : BaseDesc
$prop : string
$parents : array<string|int, object>
$visited : SplObjectStorage<object, null>

        
On this page

Search results