class NodeReader

The NodeReader provides some convenience methods for reading information from an object graph node.

Methods

__construct(array $options = [])

No description

boolean
hasType(Node $node = null, string|object $type)

Checks whether a node has a certain type.

string|null
getFirstValueString(Node $node = null, string|object $property, $default = null)

Reads a property from a node and converts it into a string.

string|null
getFirstValueIRI(Node $node = null, string|object $property, IRI $default = null)

Reads a property from a node and converts it into a IRI.

string|null
getFirstValueNode(Node $node = null, string|object $property, Node $default = null)

Reads a property from a node and returns it as a Node.

boolean
hasPropertyValue(Node $node = null, string|object $property, string|object $value)

Checks whether a node has a specific value for a property.

boolean
hasProperty(Node $node = null, string|object $property)

Checks whether the node has at least one value for a property.

getLocalizedString(Node $node = null, $property, $language, $default = null)

Get the language-tagged-string for the property in the specified language.

array
getAllValuesString(Node $node = null, string|object $property)

Reads all values from a node and returns them as a string array.

array
getAllValuesIRI(Node $node = null, string|object $property)

Reads all values from a node and returns them as a IRI array.

array
getAllValuesNode(Node $node = null, string|object $property)

Reads all values from a node and returns them as a Node array.

Details

at line 20
__construct(array $options = [])

Parameters

array $options

at line 41
boolean hasType(Node $node = null, string|object $type)

Checks whether a node has a certain type.

Parameters

Node $node The node to work on.
string|object $type The type to check for.

Return Value

boolean

at line 85
string|null getFirstValueString(Node $node = null, string|object $property, $default = null)

Reads a property from a node and converts it into a string.

If the property has multiple values only the first is returned. If no value is found or the node is null, the default is returned.

Parameters

Node $node The node to work on.
string|object $property The property to read.
$default The default that is returned if no value for the property exists on the node.

Return Value

string|null

at line 106
string|null getFirstValueIRI(Node $node = null, string|object $property, IRI $default = null)

Reads a property from a node and converts it into a IRI.

If the property has multiple values only the first is returned. If no value is found, value is a literal or the node is null, the default is returned.

Parameters

Node $node The node to work on.
string|object $property The property to read.
IRI $default The default that is returned if no value for the property exists on the node.

Return Value

string|null

at line 127
string|null getFirstValueNode(Node $node = null, string|object $property, Node $default = null)

Reads a property from a node and returns it as a Node.

If the property has multiple values only the first is returned. If no value is found, value is a literal or the node is null, the default is returned.

Parameters

Node $node The node to work on.
string|object $property The property to read.
Node $default The default that is returned if no value for the property exists on the node.

Return Value

string|null

at line 146
boolean hasPropertyValue(Node $node = null, string|object $property, string|object $value)

Checks whether a node has a specific value for a property.

Parameters

Node $node The node to work on.
string|object $property The property to read.
string|object $value The expected value.

Return Value

boolean

at line 175
boolean hasProperty(Node $node = null, string|object $property)

Checks whether the node has at least one value for a property.

Parameters

Node $node The node to work on.
string|object $property The property to read.

Return Value

boolean

at line 198
getLocalizedString(Node $node = null, $property, $language, $default = null)

Get the language-tagged-string for the property in the specified language.

If no value is found for the specified language, the default is returned.

Parameters

Node $node
$property
$language
$default

at line 215
array getAllValuesString(Node $node = null, string|object $property)

Reads all values from a node and returns them as a string array.

Parameters

Node $node The node to work on.
string|object $property The property to read.

Return Value

array

at line 235
array getAllValuesIRI(Node $node = null, string|object $property)

Reads all values from a node and returns them as a IRI array.

Only converts the Node IDs of nodes into IRI, literal values are skipped.

Parameters

Node $node The node to work on.
string|object $property The property to read.

Return Value

array

at line 253
array getAllValuesNode(Node $node = null, string|object $property)

Reads all values from a node and returns them as a Node array.

Returns only nodes, literal values are skipped.

Parameters

Node $node The node to work on.
string|object $property The property to read.

Return Value

array