DataFactory
in package
implements
DataFactoryInterface
Description of DataFactory
Tags
Table of Contents
Interfaces
Properties
- $enforceConstructor : bool
- $blankNodes : array<string, WeakReference<string|int, BlankNode>>
- $defaultGraph : DefaultGraph
- $literals : array<string, WeakReference<string|int, Literal>>
- $namedNodes : array<string, WeakReference<string|int, NamedNode>>
- $quads : array<string, WeakReference<string|int, Quad>>
Methods
- blankNode() : BlankNodeInterface
- Creates a new RDF blank node.
- checkCall() : bool
- defaultGraph() : DefaultGraphInterface
- Returns an RDF default graph object.
- getCacheCounts() : array<string|int, stdClass>
- importQuad() : QuadInterface
- Wrapper for importTerm() to make phpstan happy.
- importTerm() : TermInterface
- literal() : Literal
- Creates a new RDF literal.
- namedNode() : NamedNodeInterface
- Creates a new RDF named node.
- quad() : Quad
- Creates a new RDF quad.
- quadNoSubject() : QuadNoSubject
- Creates a new RDF quadNoSubject.
- hashLiteral() : string
- hashQuad() : string
- hashTerm() : string
Properties
$enforceConstructor
public
static bool
$enforceConstructor
= true
$blankNodes
private
static array<string, WeakReference<string|int, BlankNode>>
$blankNodes
= []
$defaultGraph
private
static DefaultGraph
$defaultGraph
$literals
private
static array<string, WeakReference<string|int, Literal>>
$literals
= []
$namedNodes
private
static array<string, WeakReference<string|int, NamedNode>>
$namedNodes
= []
$quads
private
static array<string, WeakReference<string|int, Quad>>
$quads
= []
Methods
blankNode()
Creates a new RDF blank node.
public
static blankNode([string|Stringable|null $iri = null ]) : BlankNodeInterface
Parameters
- $iri : string|Stringable|null = null
Return values
BlankNodeInterfacecheckCall()
public
static checkCall() : bool
Return values
booldefaultGraph()
Returns an RDF default graph object.
public
static defaultGraph() : DefaultGraphInterface
Return values
DefaultGraphInterfacegetCacheCounts()
public
static getCacheCounts() : array<string|int, stdClass>
Return values
array<string|int, stdClass>importQuad()
Wrapper for importTerm() to make phpstan happy.
public
static importQuad(QuadInterface $quad) : QuadInterface
Parameters
- $quad : QuadInterface
Return values
QuadInterfaceimportTerm()
public
static importTerm(TermInterface $term[, bool $recursive = true ]) : TermInterface
Parameters
- $term : TermInterface
- $recursive : bool = true
Return values
TermInterfaceliteral()
Creates a new RDF literal.
public
static literal(int|float|string|bool|Stringable $value[, string|Stringable|null $lang = null ][, string|Stringable|null $datatype = null ]) : Literal
If the $datatype is null or empty, it must be set according to the $value and $lang parameter values:
- if $lang is not empty, the $datatype must be set to
http://www.w3.org/1999/02/22-rdf-syntax-ns#langString
- if $lang is empty or null, the $datatype depends on the PHP type of the
$value parameter:
- bool -
http://www.w3.org/2001/XMLSchema#boolean
- int -
http://www.w3.org/2001/XMLSchema#integer
- float -
http://www.w3.org/2001/XMLSchema#decimal
- string -
http://www.w3.org/2001/XMLSchema#string
- Stringable object -
http://www.w3.org/2001/XMLSchema#string
or any other more precise XSD datatype if the implementation is able to derive it from the object class
- bool -
The created literal must have valid combination of datatype and lang tag (meaning the datatype is rdf:langString if and only if the literal has a lang tag). It's up to the implementation how to assure it. Both throwing an exception and one of $lang/$datatype taking precedense over the other are considered valid solutions. Of course the implementation behavior should be documented.
See https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal for a reference.
Parameters
- $value : int|float|string|bool|Stringable
-
Literal's value. Only values which can be casted to a string are allowed so it's clear how to obtain literal's value lexical form (see the RDF specification mentioned above). The lexical forms of scalar values must be created (returned by the getValue() method) in a way that back-casting them to the scalar type gives an equal value (probably the only tricky case here is boolean
false
). - $lang : string|Stringable|null = null
-
Literal's lang tag. If null or empty string, the literal is assumed not to have a lang tag (as an empty lang tag is not allowed in RDF).
- $datatype : string|Stringable|null = null
-
Literal's datatype. If it's null, the datatype must be assigned according to the $lang and $value parameter values. The detailed procedure is described above.
Return values
LiteralnamedNode()
Creates a new RDF named node.
public
static namedNode(string|Stringable $iri) : NamedNodeInterface
Parameters
- $iri : string|Stringable
Return values
NamedNodeInterfacequad()
Creates a new RDF quad.
public
static quad(TermInterface $subject, NamedNodeInterface $predicate, TermInterface $object[, NamedNodeInterface|BlankNodeInterface|DefaultGraphInterface|null $graph = null ]) : Quad
Parameters
- $subject : TermInterface
- $predicate : NamedNodeInterface
- $object : TermInterface
- $graph : NamedNodeInterface|BlankNodeInterface|DefaultGraphInterface|null = null
Return values
QuadquadNoSubject()
Creates a new RDF quadNoSubject.
public
static quadNoSubject(NamedNodeInterface $predicate, TermInterface $object[, NamedNodeInterface|BlankNodeInterface|DefaultGraphInterface|null $graphIri = null ]) : QuadNoSubject
Parameters
- $predicate : NamedNodeInterface
- $object : TermInterface
- $graphIri : NamedNodeInterface|BlankNodeInterface|DefaultGraphInterface|null = null
Return values
QuadNoSubjecthashLiteral()
private
static hashLiteral(string $value, string|null $lang, string $datatype) : string
Parameters
- $value : string
- $lang : string|null
- $datatype : string
Return values
stringhashQuad()
private
static hashQuad(TermInterface $subject, TermInterface $predicate, TermInterface $object, TermInterface $graph) : string
Parameters
- $subject : TermInterface
- $predicate : TermInterface
- $object : TermInterface
- $graph : TermInterface
Return values
stringhashTerm()
private
static hashTerm(TermInterface $t) : string
Parameters
- $t : TermInterface