NodeInterface
in
A generic interface for nodes in a JSON-LD graph.
Tags
Table of Contents
Methods
- addPropertyValue() : self
- Adds a value to a property of the node
- addType() : self
- Add a type to this node
- equals() : bool
- Compares this node object to the specified value.
- getGraph() : null|GraphInterface
- Get the graph the node belongs to
- getId() : string|null
- Get ID
- getNodesWithThisType() : array<string|int, NodeInterface>
- Get the nodes which have this node as their type
- getProperties() : array<string|int, mixed>
- Get the properties of this node
- getProperty() : mixed
- Get the value of a property
- getReverseProperties() : array<string|int, mixed>
- Get the reverse properties of this node
- getReverseProperty() : null|NodeInterface|array<string|int, NodeInterface>
- Get the nodes of a reverse property
- getType() : null|NodeInterface|array<string|int, NodeInterface>
- Get node type
- isBlankNode() : bool
- Is this node a blank node
- removeFromGraph() : self
- Removes the node from the graph
- removeProperty() : self
- Removes a property and all it's values
- removePropertyValue() : self
- Removes a property value
- removeType() : self
- Remove a type from this node
- setProperty() : self
- Set a property of the node
- setType() : self
- Set the node type
Methods
addPropertyValue()
Adds a value to a property of the node
public
addPropertyValue(string $property, mixed $value) : self
If the value already exists, it won't be added again, i.e., there won't be any duplicate property values.
If the value is or contains a reference to a node which is not part of the graph, the referenced node will added to the graph as well. If the referenced node is already part of another graph a copy of the node will be created and added to the graph.
Parameters
- $property : string
-
The name of the property.
- $value : mixed
-
The value of the property. This MUST NOT be an array.
Tags
Return values
selfaddType()
Add a type to this node
public
addType(NodeInterface $type) : self
Parameters
- $type : NodeInterface
Return values
selfequals()
Compares this node object to the specified value.
public
equals(mixed $other) : bool
Parameters
- $other : mixed
-
The value this instance should be compared to.
Return values
bool —Returns true if the passed value is the same as this instance; false otherwise.
getGraph()
Get the graph the node belongs to
public
getGraph() : null|GraphInterface
Return values
null|GraphInterface —Returns the graph the node belongs to or null if the node doesn't belong to any graph.
getId()
Get ID
public
getId() : string|null
Return values
string|null —The ID of the node or null.
getNodesWithThisType()
Get the nodes which have this node as their type
public
getNodesWithThisType() : array<string|int, NodeInterface>
This will return all nodes that link to this Node instance via the
Tags
Return values
array<string|int, NodeInterface> —Returns the node(s) having this node as their type.
getProperties()
Get the properties of this node
public
getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an associative array containing all properties of this node. The key is the property name whereas the value is the property's value.
getProperty()
Get the value of a property
public
getProperty(string $property) : mixed
Parameters
- $property : string
-
The name of the property.
Return values
mixed —Returns the value of the property or null if the property doesn't exist.
getReverseProperties()
Get the reverse properties of this node
public
getReverseProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an associative array containing all reverse properties of this node. The key is the property name whereas the value is an array of nodes linking to this instance via that property.
getReverseProperty()
Get the nodes of a reverse property
public
getReverseProperty(string $property) : null|NodeInterface|array<string|int, NodeInterface>
This will return all nodes that link to this Node instance via the specified property.
Parameters
- $property : string
-
The name of the reverse property.
Return values
null|NodeInterface|array<string|int, NodeInterface> —Returns the node(s) pointing to this instance via the specified property or null if no such node exists.
getType()
Get node type
public
getType() : null|NodeInterface|array<string|int, NodeInterface>
Return values
null|NodeInterface|array<string|int, NodeInterface> —Returns the type(s) of this node.
isBlankNode()
Is this node a blank node
public
isBlankNode() : bool
A blank node is a node whose identifier has just local meaning. It has
therefore a node identifier with the prefix _:
or no
identifier at all.
Return values
bool —Returns true if the node is a blank node, otherwise false.
removeFromGraph()
Removes the node from the graph
public
removeFromGraph() : self
This will also remove all references to and from other nodes in this node's graph.
Return values
selfremoveProperty()
Removes a property and all it's values
public
removeProperty(string $property) : self
Parameters
- $property : string
-
The name of the property to remove.
Return values
selfremovePropertyValue()
Removes a property value
public
removePropertyValue(string $property, mixed $value) : self
Parameters
- $property : string
-
The name of the property.
- $value : mixed
-
The value of the property. This MUST NOT be an array.
Return values
selfremoveType()
Remove a type from this node
public
removeType(NodeInterface $type) : self
Parameters
- $type : NodeInterface
Return values
selfsetProperty()
Set a property of the node
public
setProperty(string $property, mixed $value) : self
If the value is or contains a reference to a node which is not part of the graph, the referenced node will added to the graph as well. If the referenced node is already part of another graph a copy of the node will be created and added to the graph.
Parameters
- $property : string
-
The name of the property.
- $value : mixed
-
The value of the property. This MUST NOT be an array. Use null to remove the property.
Tags
Return values
selfsetType()
Set the node type
public
setType(mixed $type) : self
Parameters
- $type : mixed