DatasetNodeInterface
extends
TermInterface, DatasetInterface
in
Node-oriented graph API interface.
Basically a union of the rdfInterface\QuadInterface and the rdfInterface\DatasetInterface.
All methods inherited from the rdfInterface\DatasetInterface and returning the rdfInterface\DatasetNodeInterface should:
- process only quads having the DatasetNodeInterface's node as a subject
- preserve all other quads
Tags
Table of Contents
Methods
- __toString() : string
- Should return:
- add() : void
- Adds quad(s) to the dataset.
- any() : bool
- Checks if any quad in the dataset matches a given filter.
- copy() : DatasetInterface
- Creates a copy of the dataset.
- copyExcept() : DatasetInterface
- Creates a copy of the dataset.
- delete() : DatasetInterface
- In-place removes quads from the dataset.
- deleteExcept() : DatasetInterface
- In-place removes quads from the dataset.
- equals() : bool
- every() : bool
- Checks if all quads in the dataset match a given filter.
- factory() : DatasetNodeInterface
- Creates a DatasetNodeInterface object.
- forEach() : void
- Iterates trough all quads replacing them with a callback result.
- getDataset() : DatasetInterface
- The actual dataset (and not its copy) should be returned.
- getGraph() : TermInterface
- Fetches graph of a first quad matching a given filter or null if no quad matches the filter.
- getGraphValue() : mixed
- Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
- getIterator() : QuadIteratorInterface
- Returns QuadIteratorInterface iterating over dataset's quads.
- getNode() : TermInterface
- getObject() : TermInterface
- Fetches object of a first quad matching a given filter or null if no quad matches the filter.
- getObjectValue() : mixed
- Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
- getPredicate() : TermInterface
- Fetches subject of a first quad matching a given filter or null if no quad matches the filter.
- getPredicateValue() : mixed
- Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
- getSubject() : TermInterface
- Fetches subject of a first quad matching a given filter or null if no quad matches the filter.
- getSubjectValue() : mixed
- Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
- getValue() : mixed
- listGraphs() : TermIteratorInterface
- Fetches an iterator over unique set of dataset quad graphs.
- listObjects() : TermIteratorInterface
- Fetches an iterator over unique set of dataset quad objects.
- listPredicates() : TermIteratorInterface
- Fetches an iterator over unique set of dataset quad predicates.
- listSubjects() : TermIteratorInterface
- Fetches an iterator over unique set of dataset quad subjects.
- map() : DatasetNodeInterface
- Quads with subject other than DatasetNodeInterface's node should be returned untouched.
- none() : bool
- Checks if no quad in the dataset matches a given filter.
- offsetExists() : bool
- Checks if a given offset exists.
- offsetGet() : QuadInterface
- Returns a quad matching the $offset.
- offsetSet() : void
- Assigns a new value to the quad matching the $offset.
- offsetUnset() : void
- Removes a quad matching the $offset.
- reduce() : mixed
- union() : DatasetNodeInterface
- Only those quads from $other which have subject matching the DatasetNodeInterface's node are added.
- withDataset() : DatasetNodeInterface
- withNode() : DatasetNodeInterface
- xor() : DatasetNodeInterface
- The resulting dataset should contain: - all quads of the DatasetNodeInterface with subject other than the node - xor between triples of the DatasetNodeInterface with subject being the node and triples of the $other with subject being the node
Methods
__toString()
Should return:
public
__toString() : string
- an URI for named nodes and blank nodes
- a value in lexical form for literals
For all other kind of terms the return value depends on the implementation
Return values
stringadd()
Adds quad(s) to the dataset.
public
add(QuadInterface|Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $quads) : void
Does not check if the quad subject matches the DatasetNodeInterface's object node.
Parameters
- $quads : QuadInterface|Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
any()
Checks if any quad in the dataset matches a given filter.
public
any(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : bool
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Return values
boolcopy()
Creates a copy of the dataset.
public
copy([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : DatasetInterface
If $filter is provided, the copy contains only quads matching the $filter.
$filter can be specified as:
- An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single Quad)
- An object implementing the \rdfInterface\QuadIteratorInterface (e.g. another Dataset)
- A callable with signature
fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool
All quads for which the callable returns true are copied.
An in-place equivalent of a call using the $filter is the deleteExcept() method.
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
DatasetInterfacecopyExcept()
Creates a copy of the dataset.
public
copyExcept(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : DatasetInterface
If $filter is provided, the copy contains only quads not matching the $filter.
$filter can be specified as:
- An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single Quad)
- An object implementing the \rdfInterface\QuadIteratorInterface (e.g. another Dataset)
- A callable with signature
fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool
All quads for which the callable returns true are copied.
An in-place equivalent of a call using the $filter is the delete() method.
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Return values
DatasetInterfacedelete()
In-place removes quads from the dataset.
public
delete(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : DatasetInterface
All quads matching the $filter parameter are removed.
$filter can be specified as:
- An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single Quad)
- An object implementing the \rdfInterface\QuadIteratorInterface (e.g. another Dataset)
- A callable with signature
fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool
All quads for which the callable returns true are copied.
An immputable equivalent is the copyExcept($filter) method.
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Tags
Return values
DatasetInterface —a dataset containing removed quads.
deleteExcept()
In-place removes quads from the dataset.
public
deleteExcept(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : DatasetInterface
All quads but ones matching the $filter parameter are removed.
$filter can be specified as:
- An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single Quad)
- An object implementing the \rdfInterface\QuadIteratorInterface (e.g. another Dataset)
- A callable with signature
fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool
All quads for which the callable returns true are copied.
An immputable equivalent is the copy($filter) method.
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Tags
Return values
DatasetInterface —a dataset containing removed quads.
equals()
public
equals(DatasetInterface|TermCompareInterface|DatasetNodeInterface $termOrDataset) : bool
Parameters
- $termOrDataset : DatasetInterface|TermCompareInterface|DatasetNodeInterface
Return values
boolevery()
Checks if all quads in the dataset match a given filter.
public
every(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : bool
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Return values
boolfactory()
Creates a DatasetNodeInterface object.
public
static factory([TermInterface|null $node = null ][, QuadIteratorAggregateInterface|QuadIteratorInterface|null $quads = null ]) : DatasetNodeInterface
Parameters
- $node : TermInterface|null = null
-
Node has to be provided. If it is null, \BadMethodCallException should be thrown (null is accepted in the signature only to match the rdfInterface\Dataset::factory() signature). $node does not have to exist in the $dataset.
- $quads : QuadIteratorAggregateInterface|QuadIteratorInterface|null = null
Tags
Return values
DatasetNodeInterfaceforEach()
Iterates trough all quads replacing them with a callback result.
public
forEach(callable $fn[, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : void
If the callback returns null, the quad should be removed from the dataset.
Parameters
- $fn : callable
-
with signature
fn(Quad, Dataset): ?Quad
to be run an all quads - $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
getDataset()
The actual dataset (and not its copy) should be returned.
public
getDataset() : DatasetInterface
This means if quads are in-place added/removed from the returned object, these changes are shared with the DatasetNodeInterface object.
Return values
DatasetInterfacegetGraph()
Fetches graph of a first quad matching a given filter or null if no quad matches the filter.
public
getGraph([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermInterface —| null
getGraphValue()
Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
public
getGraphValue([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
getIterator()
Returns QuadIteratorInterface iterating over dataset's quads.
public
getIterator([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : QuadIteratorInterface
If $filter is provided, the iterator includes only quads matching the filter.
$filter can be specified as:
- An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single Quad)
- An object implementing the \rdfInterface\QuadIteratorInterface (e.g. another Dataset)
- A callable with signature
fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool
All quads for which the callable returns true are copied.
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
QuadIteratorInterfacegetNode()
public
getNode() : TermInterface
Return values
TermInterfacegetObject()
Fetches object of a first quad matching a given filter or null if no quad matches the filter.
public
getObject([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermInterface —| null
getObjectValue()
Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
public
getObjectValue([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
getPredicate()
Fetches subject of a first quad matching a given filter or null if no quad matches the filter.
public
getPredicate([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermInterface —| null
getPredicateValue()
Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
public
getPredicateValue([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
getSubject()
Fetches subject of a first quad matching a given filter or null if no quad matches the filter.
public
getSubject([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermInterface —| null
getSubjectValue()
Returns result of calling the getValue() method on a subject of a first quad matching a given filter or null if no quad matches the filter.
public
getSubjectValue([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
getValue()
public
getValue() : mixed
listGraphs()
Fetches an iterator over unique set of dataset quad graphs.
public
listGraphs([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermIteratorInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermIteratorInterfacelistObjects()
Fetches an iterator over unique set of dataset quad objects.
public
listObjects([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermIteratorInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermIteratorInterfacelistPredicates()
Fetches an iterator over unique set of dataset quad predicates.
public
listPredicates([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermIteratorInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermIteratorInterfacelistSubjects()
Fetches an iterator over unique set of dataset quad subjects.
public
listSubjects([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermIteratorInterface
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermIteratorInterfacemap()
Quads with subject other than DatasetNodeInterface's node should be returned untouched.
public
map(callable $fn[, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : DatasetNodeInterface
Parameters
- $fn : callable
-
function applied to every quad with signature
fn(quad, datasetNode)
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
DatasetNodeInterfacenone()
Checks if no quad in the dataset matches a given filter.
public
none(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : bool
Parameters
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
Return values
booloffsetExists()
Checks if a given offset exists.
public
offsetExists(QuadCompareInterface|callable|int<0, 0> $offset) : bool
The offset can be specified as:
- An object implementing the \rdfInterface\QuadCompare interface.
- A callable with the
fn(\rdfInterface\Quad, \rdfInterface\Dataset): bool
signature. Matching quads are the ones for which the callable returnstrue
. If more than one quad is matched \UnexpectedValueException must be thrown. -
0
. This is a shorthand syntax for checking if the dataset is empty.
If the $offset is specified differently, \UnexpectedValueException is thrown.
If exactly one quad is matched, true
is returned.
If no quad is matched, false
is returned.
If the $offset matches more than one quad,
\rdfInterface\MultipleQuadsMatchedException is thrown.
Parameters
- $offset : QuadCompareInterface|callable|int<0, 0>
Tags
Return values
booloffsetGet()
Returns a quad matching the $offset.
public
offsetGet(QuadCompareInterface|callable|int<0, 0> $offset) : QuadInterface
The $offset can be specified as:
- An object implementing the \rdfInterface\QuadCompare interface.
- A callable with the
fn(\rdfInterface\Quad, \rdfInterface\Dataset): bool
signature. Matching quads are the ones for which the callable returnstrue
. -
0
Returns any single quad. The main use case is enabling the$dataset[0] ?? $defaultQuad
syntax for "unpacking" a dataset containing one or zero quads. As quads within a dataset don't have order, it makes no sense to access them using other integer offsets and an attempt of doing so must throw an \UnexpectedValueException.
If the $offset is specified differently, \UnexpectedValueException is trown.
If the $offset is 0
and the dataset is not empty, any quad is returned.
If exactly one quad is matched, it is returned.
If the $offset matches more than one quad,
\rdfInterface\MultipleQuadsMatchedException is thrown.
If the $offset matches no quad, \UnexpectedValueException is thrown.
Parameters
- $offset : QuadCompareInterface|callable|int<0, 0>
Tags
Return values
QuadInterfaceoffsetSet()
Assigns a new value to the quad matching the $offset.
public
offsetSet(QuadCompareInterface|callable $offset, QuadInterface $value) : void
Offset can be specified as:
- An object implementing the \rdfInterface\QuadCompare interface. If more than one quad is matched \OutOfBoundsException must be thrown.
- A callable with the
fn(\rdfInterface\Quad, \rdfInterface\Dataset): bool
signature. Matching quads are the ones for which the callable returnstrue
. If more than one quad is matched \OutOfBoundsException must be thrown. - NULL. In such a case the quad in $value is just added to the underalying dataset without checking if its subject matches DatasetNodeInterface object's node.
Parameters
- $offset : QuadCompareInterface|callable
- $value : QuadInterface
Tags
offsetUnset()
Removes a quad matching the $offset.
public
offsetUnset(QuadCompareInterface|callable $offset) : void
Offset can be specified as:
- An object implementing the \rdfInterface\QuadCompare interface.
- A callable with the
fn(\rdfInterface\Quad, \rdfInterface\Dataset): bool
signature. Matching quads are the ones for which the callable returnstrue
.
If the $offset is specified differently, \UnexpectedValueException is trown.
If the $offset matches more than one quad, \rdfInterface\MultipleQuadsMatchedException is thrown. If exactly one quad is matched, it is removed. If no quad is matched, nothing happens.
Parameters
- $offset : QuadCompareInterface|callable
Tags
reduce()
public
reduce(callable $fn[, mixed $initialValue = null ][, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed
Parameters
- $fn : callable
-
aggregate function with signature
fn(accumulator, quad, dataset)
applied on each quad and returns last callback result - $initialValue : mixed = null
- $filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
union()
Only those quads from $other which have subject matching the DatasetNodeInterface's node are added.
public
union(QuadInterface|QuadIteratorInterface|QuadIteratorAggregateInterface $other) : DatasetNodeInterface
Parameters
Return values
DatasetNodeInterfacewithDataset()
public
withDataset(DatasetInterface $dataset) : DatasetNodeInterface
Parameters
- $dataset : DatasetInterface
-
Replaces the underlaying dataset with a given one. The $dataset object should be used directly so any in-place modification performed on it are reflected in the DatasetNodeInterface object and vice versa.
Return values
DatasetNodeInterfacewithNode()
public
withNode(TermInterface $node) : DatasetNodeInterface
Parameters
- $node : TermInterface
Return values
DatasetNodeInterfacexor()
The resulting dataset should contain: - all quads of the DatasetNodeInterface with subject other than the node - xor between triples of the DatasetNodeInterface with subject being the node and triples of the $other with subject being the node
public
xor(QuadInterface|QuadIteratorInterface|QuadIteratorAggregateInterface $other) : DatasetNodeInterface