Documentation

DocumentInterface

JSON-LD document interface

Tags
author

Markus Lanthaler mail@markus-lanthaler.com

Table of Contents

Methods

containsGraph()  : bool
Check whether the document contains a graph with the specified name
createGraph()  : GraphInterface
Creates a new graph which is linked to this document
getGraph()  : GraphInterface|null
Get a graph by name
getGraphNames()  : array<string|int, string>
Get graph names
getIri()  : string|IRI
Get the document's IRI
removeGraph()  : self
Removes a graph from the document
setIri()  : self
Set the document's IRI

Methods

containsGraph()

Check whether the document contains a graph with the specified name

public containsGraph(string $name) : bool
Parameters
$name : string

The graph name.

Return values
bool

Returns true if the document contains a graph with the specified name; false otherwise.

createGraph()

Creates a new graph which is linked to this document

public createGraph(string|IRI $name) : GraphInterface

If there exists already a graph with the passed name in the document, that graph will be returned instead of creating a new one.

Parameters
$name : string|IRI

The graph's name.

Return values
GraphInterface

The newly created graph.

getGraph()

Get a graph by name

public getGraph([null|string $name = null ]) : GraphInterface|null
Parameters
$name : null|string = null

The name of the graph to retrieve. If null is passed, the default will be returned.

Return values
GraphInterface|null

Returns the graph if found; null otherwise.

getGraphNames()

Get graph names

public getGraphNames() : array<string|int, string>
Return values
array<string|int, string>

Returns the names of all graphs in the document.

getIri()

Get the document's IRI

public getIri([bool $asObject = false ]) : string|IRI
Parameters
$asObject : bool = false

If set to true, the return value will be an object; otherwise a string.

Return values
string|IRI

The document's IRI (might be empty).

removeGraph()

Removes a graph from the document

public removeGraph([null|string|GraphInterface $graph = null ]) : self
Parameters
$graph : null|string|GraphInterface = null

The graph (or its name) to remove. If null is passed, the default will be reset.

Return values
self

setIri()

Set the document's IRI

public setIri(mixed $iri) : self
Parameters
$iri : mixed
Return values
self

        
On this page

Search results