Documentation

DatasetNodeInterface extends TermInterface, DatasetInterface

Node-oriented graph API interface.

Tags
author

zozlak

Table of Contents

Methods

__toString()  : string
Should return:
add()  : void
Adds quad(s) to the dataset.
any()  : bool
Checks if any quad of a dataset node with subject matching dataset node's node match a given filter.
copy()  : DatasetNodeInterface
Creates a copy of the dataset node.
copyExcept()  : DatasetNodeInterface
Creates a copy of the dataset node.
delete()  : DatasetInterface
In-place removes quads from the dataset node.
deleteExcept()  : DatasetInterface
In-place removes quads from the dataset node.
equals()  : bool
Depending on the type of the $termOrDataset:
every()  : bool
Checks if all quads of a dataset node with subject matching dataset node's node match a given filter.
factory()  : DatasetNodeInterface
Creates a DatasetNodeInterface object.
forEach()  : void
In-place modifies all dataset node quads using a given callback.
getDataset()  : DatasetInterface
The actual dataset should be returned.
getGraph()  : TermInterface|null
Fetches graph of a first quad having subject matching dataset node's node and a given filter or null otherwise.
getGraphValue()  : mixed
Returns result of calling the getValue() method on a subject of a first quad having subject matching dataset node's node and matching a given filter or null otherwise.
getIterator()  : QuadIteratorInterface
Returns an iterator over datase node's quads having subject matching dataset node's node and optionally matching a given filter.
getNode()  : TermInterface
Returns the node associated with a given DatasetNodeInterface object
getObject()  : TermInterface|null
Fetches object of a first quad having subject matching dataset node's node and a given filter or null otherwise.
getObjectValue()  : mixed
Returns result of calling the getValue() method on a subject of a first quad having subject matching dataset node's node and matching a given filter or null otherwise.
getPredicate()  : TermInterface|null
Fetches subject of a first quad having subject matching dataset node's node and a given filter or null otherwise.
getPredicateValue()  : mixed
Returns result of calling the getValue() method on a subject of a first quad having subject matching dataset node's node and matching a given filter or null otherwise.
getSubject()  : TermInterface|null
Fetches subject of a first quad having subject matching dataset node's node and a given filter or null otherwise.
getSubjectValue()  : mixed
Returns result of calling the getValue() method on a subject of a first quad having subject matching dataset node's node and matching a given filter or null otherwise.
getValue()  : mixed
Returns dataset node node's value
listGraphs()  : TermIteratorInterface
Fetches an iterator over unique set of dataset node quad graphs having subject matching dataset node's node and optionally matching a given filter.
listObjects()  : TermIteratorInterface
Fetches an iterator over unique set of dataset node quad objects having subject matching dataset node's node and optionally matching a given filter.
listPredicates()  : TermIteratorInterface
Fetches an iterator over unique set of dataset node quad predicates having subject matching dataset node's node and optionally matching a given filter.
listSubjects()  : TermIteratorInterface
Fetches an iterator over unique set of dataset quad subjects having subject matching dataset node's node and optionally matching a given filter.
map()  : DatasetNodeInterface
Returns a new dataset node from quads processed with a given callback function.
none()  : bool
Checks if none of quads of a dataset node with subject matching dataset node's node match a given filter.
offsetExists()  : bool
Checks if a given offset exists. The check is performed only among quads which subject matching dataset node's node.
offsetGet()  : QuadInterface
Returns a quad matching the $offset and having a subject matching dataset node's node.
offsetSet()  : void
Assigns a new value to the quad matching the $offset and having subject matching dataset node's node.
offsetUnset()  : void
Removes a quad matching the $offset and having subject matching dataset node's node.
reduce()  : mixed
Performs a reduce operation on the dataset node quads with subject matching the dataset node's node.
union()  : DatasetNodeInterface
Returns a new dataset node being a union of the current one (including both quads matching and not matching dataset node's node) and quads from the $other mathing the dataset node's node.
withDataset()  : DatasetNodeInterface
Returns a new dataset node sharing the node with the current one but using a given dataset.
withNode()  : DatasetNodeInterface
Returns a new dataset node which shares the underlaying dataset with the current one but has another node.
xor()  : DatasetNodeInterface
Returns a new dataset node containing:

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
string

add()

Adds quad(s) to the dataset.

public add(QuadInterface|QuadNoSubjectInterface|Traversable<string|int, QuadInterface|QuadNoSubjectInterface>|array<string|int, QuadInterface|QuadNoSubjectInterface$quads) : void

Does not check if the quad subject matches the DatasetNodeInterface's object node.

Allows passing QuadNoSubjectInterface. They must be converted to quads using the DatasetNodeInterface's node as a subject.

Parameters
$quads : QuadInterface|QuadNoSubjectInterface|Traversable<string|int, QuadInterface|QuadNoSubjectInterface>|array<string|int, QuadInterface|QuadNoSubjectInterface>

copy()

Creates a copy of the dataset node.

public copy([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ][, bool $includeOther = true ]) : DatasetNodeInterface

If $filter is provided, quads with subject matching DatasetNodeInterface's node and not matching the $filter are skipped.

The $filter can be specified as:

  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • A callable with signature fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool All quads for which the callable returns true are copied.

Quads with subject other than dataset node's node are copied based on the $includeOther parameter value;

An in-place equivalent of a call using the $filter is the deleteExcept() method.

Parameters
$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
$includeOther : bool = true

should quads with subject other than dataset node's node be copied

Tags
see
deleteExcept()
Return values
DatasetNodeInterface

copyExcept()

Creates a copy of the dataset node.

public copyExcept(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter[, bool $includeOther = true ]) : DatasetNodeInterface

If $filter is provided, the copy contains only quads with subject matching dateset node's node and not matching the $filter.

The $filter can be specified as:

  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • A callable with signature fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool All quads for which the callable returns true are copied.

Quads with subject other than dataset node's node are copied based on the $includeOther parameter value;

An in-place equivalent of a call using the $filter is the delete() method.

Parameters
$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable
$includeOther : bool = true

should quads with subject other than dataset node's node be copied

Tags
see
delete()
Return values
DatasetNodeInterface

delete()

In-place removes quads from the dataset node.

public delete([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : DatasetInterface

All quads matching the $filter parameter and having a subject matching dataset node's node are removed.

The $filter can be specified as:

  • null meaning "remove all".
  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • 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|null = null
Tags
see
copyExcept()
Return values
DatasetInterface

a dataset containing removed quads.

deleteExcept()

In-place removes quads from the dataset node.

public deleteExcept(QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable $filter) : DatasetInterface

All quads with subject matching dataset node's node but ones matching the $filter parameter are removed.

The $filter can be specified as:

  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • 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
see
copy()
Return values
DatasetInterface

a dataset containing removed quads.

equals()

Depending on the type of the $termOrDataset:

public equals(DatasetInterface|TermCompareInterface|DatasetNodeInterface $termOrDataset) : bool
  • If $termOrDataset is a TermCompareInterface, compares against the DatasetNodeInterface's node.
  • If $termOrDataset is a DatasetInterface or DatasetNodeInterface, compares between the DatasetNodeInterface node's quads (quads having the node as their subject) between the DatasetNodeInterface object and the $termOrDataset object.
Parameters
$termOrDataset : DatasetInterface|TermCompareInterface|DatasetNodeInterface
Return values
bool

factory()

Creates a DatasetNodeInterface object.

public static factory([TermInterface|null $node = null ][, QuadInterface|QuadNoSubjectInterface|Traversable<string|int, QuadInterface|QuadNoSubjectInterface>|array<string|int, QuadInterface|QuadNoSubjectInterface>|null $quads = null ]) : DatasetNodeInterface
Parameters
$node : TermInterface|null = null

term to become DatasetNodeInterface object's node. If null is passed, the \BadMethodCallException must be thrown (the null value is accepted in the signature only to match the rdfInterface\Dataset::factory() signature). The $node does not have to be a subject in any of $quads.

$quads : QuadInterface|QuadNoSubjectInterface|Traversable<string|int, QuadInterface|QuadNoSubjectInterface>|array<string|int, QuadInterface|QuadNoSubjectInterface>|null = null

Quads to be stored in the dataset. Quads are added no matter if their subject matches the $node. Note that:

  • DatasetInterface can be passed as $quads because it implements the QuadIteratorAggregateInterface.
  • Further changes made to the object passed as $quads are not reflected in the DatasetNodeInterface object's dataset. If you want this behaviour, use the `(new DatasetNodeInterface($node))->withDataset($dataset).
Tags
throws
BadMethodCallException
see
DatasetNodeInterface::withDataset()
Return values
DatasetNodeInterface

forEach()

In-place modifies all dataset node quads using a given callback.

public forEach(callable $fn[, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : void

All quads with subject matching dataset node's node and the $filter parameter are modified.

The $filter can be specified as:

  • null which matches all quads.
  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • A callable with signature fn(\rdfInterface\QuadInterface, \rdfInterface\DatasetInterface): bool All quads for which the callable returns true are copied.

If the callback returns null, the quad should be removed from the dataset node.

Parameters
$fn : callable

a callback with signature fn(\rdfInterface\Quad, \rdfInterface\Dataset): \rdfInterface\Quad|null modyfying a single quad

$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null

getDataset()

The actual dataset should be returned.

public getDataset() : DatasetInterface

This means if quads are in-place added/removed to/from the returned object, these changes are shared with the DatasetNodeInterface object.

Return values
DatasetInterface

getIterator()

Returns an iterator over datase node's quads having subject matching dataset node's node and optionally matching a given filter.

public getIterator([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : QuadIteratorInterface

The $filter can be specified as:

  • null matches all quads.
  • An object implementing the \rdfInterface\QuadCompareInterface (e.g. a single quad)
  • An object implementing the \rdfInterface\QuadIteratorInterface or the \rdfInterface\QuadIteratorAggregateInterface (e.g. another dataset or dataset node)
  • 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
QuadIteratorInterface

listPredicates()

Fetches an iterator over unique set of dataset node quad predicates having subject matching dataset node's node and optionally matching a given filter.

public listPredicates([QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : TermIteratorInterface
Parameters
$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
Return values
TermIteratorInterface

map()

Returns a new dataset node from quads processed with a given callback function.

public map(callable $fn[, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ][, bool $includeOther = true ]) : DatasetNodeInterface
Parameters
$fn : callable

function applied to every quad with signature fn(\rdfInterface\QuadInterfca, \rdfInterface\DatasetNodeInterface)

$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null
$includeOther : bool = true

should quads with subject other than dataset node's node be copied

Return values
DatasetNodeInterface

offsetExists()

Checks if a given offset exists. The check is performed only among quads which subject matching dataset node's node.

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 returns true. If more than one quad is matched \UnexpectedValueException must be thrown.
  • 0. This is a shorthand syntax for checking if the dataset node contains any quad with subject matching dataset node's node.

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
throws
UnexpectedValueException
throws
MultipleQuadsMatchedException
Return values
bool

offsetGet()

Returns a quad matching the $offset and having a subject matching dataset node's node.

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 returns true.
  • 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 thrown.

If the $offset is 0 and the dataset contains any quad with subject maching dataset node's node, any of those quads 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 quads, \UnexpectedValueException is thrown.

Parameters
$offset : QuadCompareInterface|callable|int<0, 0>
Tags
throws
UnexpectedValueException
throws
MultipleQuadsMatchedException
Return values
QuadInterface

offsetSet()

Assigns a new value to the quad matching the $offset and having subject matching dataset node's node.

public offsetSet(QuadCompareInterface|callable $offset, QuadInterface $value) : void

The new quad may have a different subject.

Offset can be specified as:

  • null which is just a shorthand to add($value). In this case the $value subject does not need to match dataset node's node.
  • 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 returns true. If more than one quad is matched \OutOfBoundsException must be thrown.
Parameters
$offset : QuadCompareInterface|callable
$value : QuadInterface
Tags
see
DatasetInterface::offsetSet()
throws
UnexpectedValueException
throws
MultipleQuadsMatchedException

offsetUnset()

Removes a quad matching the $offset and having subject matching dataset node's node.

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 returns true.

If the $offset is specified differently, \UnexpectedValueException is thrown.

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
throws
UnexpectedValueException
throws
MultipleQuadsMatchedException

reduce()

Performs a reduce operation on the dataset node quads with subject matching the dataset node's node.

public reduce(callable $fn[, mixed $initialValue = null ][, QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null $filter = null ]) : mixed

The reduce operation consist of calling a given callback function on all matching quads. The first call is made with the $initialValue passed as the callback's $prevValue. Following calls pass previous callback's call return value as the next callback's call $prevValue. The return value of the last callback function call is the return value of the reduce() method.

Parameters
$fn : callable

aggregate function with signature fn(mixed $prevValue, \rdfInterface\QuadInterface, \rdfInterface\DatasetInterface)

$initialValue : mixed = null
$filter : QuadCompareInterface|QuadIteratorInterface|QuadIteratorAggregateInterface|callable|null = null

union()

Returns a new dataset node being a union of the current one (including both quads matching and not matching dataset node's node) and quads from the $other mathing the dataset node's node.

public union(QuadInterface|QuadIteratorInterface|QuadIteratorAggregateInterface $other) : DatasetNodeInterface

For an in-place union use add().

Parameters
$other : QuadInterface|QuadIteratorInterface|QuadIteratorAggregateInterface
Return values
DatasetNodeInterface

$see add()


        
On this page

Search results