Documentation

DatasetInterface extends QuadIteratorAggregateInterface, ArrayAccess, Countable, Stringable

Main, edge(quad) and Dataset-oriented Dataset API

Tags
author

zozlak

extends

\ArrayAccess<QuadInterface|QuadIteratorInterface|callable|int<0, 0>, QuadInterface>

Table of Contents

Methods

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()  : DatasetInterface
forEach()  : void
Iterates trough all quads replacing them with a callback result.
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.
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.
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()  : DatasetInterface
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()  : DatasetInterface
Returns a new dataset being a union of the current one and the $other one.
xor()  : DatasetInterface
Returns a dataset being a symmetric difference of the current dataset and the $other one.

Methods

copy()

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
Tags
see
deleteExcept
Return values
DatasetInterface

copyExcept()

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
Tags
see
delete()
Return values
DatasetInterface

delete()

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
see
copyExcept()
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
see
copy()
Return values
DatasetInterface

a dataset containing removed quads.

forEach()

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

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
QuadIteratorInterface

offsetExists()

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

offsetGet()

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

offsetSet()

Assigns a new value to the quad matching the $offset.

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

Offset can be specified as:

  • null which is just a shorthand to add($value)
  • An object implementing the \rdfInterface\QuadCompare interface. If more than one quad is matched \UnexpectedValueException 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 \UnexpectedValueException must be thrown.

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

If the $offset is null, a new quad is added to the dataset. If exactly one quad is matched by the $offset, it is updated. 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|null
$value : QuadInterface
Tags
throws
UnexpectedValueException
throws
MultipleQuadsMatchedException

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

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

        
On this page

Search results