Documentation

DatasetInterface extends QuadIteratorAggregateInterface, ArrayAccess, Countable

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

Tags
author

zozlak

extends

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

Table of Contents

__construct()  : mixed
__toString()  : string
add()  : void
Adds quad(s) to the dataset.
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
forEach()  : void
Iterates trough all quads replacing them with a callback result.
getIterator()  : QuadIteratorInterface
Returns QuadIteratorInterface iterating over dataset's quads.
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.
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|null $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|null
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 $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
Tags
Return values
void

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
Tags
Return values
QuadIteratorInterface

offsetExists()

Checks if a given offset exists.

public offsetExists(QuadCompareInterface|callable|int<0, 0> $offset) : bool

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 returns true. If more than one quad is matched \OutOfBoundsException must be thrown.
    1. This is a shorthand syntax for checking if the dataset is empty. The main use case is enabling the $dataset[0] ?? $defaultQuad syntax for "unpacking" a dataset containing one or zero quads. Passing any other integer value must throw an \OutOfBoundsException
Parameters
$offset : QuadCompareInterface|callable|int<0, 0>
Tags
throws
OutOfBoundsException
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. 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.
    1. Returns any quad (or throws \OutOfBoundsException it a dataset is empty). 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 \OutOfBoundsException.
Parameters
$offset : QuadCompareInterface|callable|int<0, 0>
Tags
throws
OutOfBoundsException
Return values
QuadInterface

offsetSet()

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 returns true. If more than one quad is matched \OutOfBoundsException must be thrown.
Parameters
$offset : QuadCompareInterface|callable
$value : QuadInterface
Tags
Return values
void

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. 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
Tags
throws
OutOfBoundsException
Return values
void

        

Search results