TypedValue
extends Value
in package
A typed value represents a value with an associated type.
Tags
Table of Contents
Properties
- $value : string
- The value in the form of a string
- $type : string
- The type of the value in the form of an IRI.
Methods
- __construct() : mixed
- Constructor
- equals() : bool
- Compares this instance to the specified value.
- fromJsonLd() : false|LanguageTaggedString|TypedValue
- Create a LanguageTaggedString or TypedValue from a JSON-LD element
- getType() : string
- Get the type
- getValue() : string
- Get the value
- setType() : self
- Set the type
- setValue() : self
- Set the value
- toJsonLd() : mixed
- Convert to expanded and flattened JSON-LD
Properties
$value
The value in the form of a string
protected
string
$value
$type
The type of the value in the form of an IRI.
private
string
$type
Methods
__construct()
Constructor
public
__construct(string $value, string $type) : mixed
Parameters
- $value : string
-
The value.
- $type : string
-
The type.
equals()
Compares this instance 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.
fromJsonLd()
Create a LanguageTaggedString or TypedValue from a JSON-LD element
public
static fromJsonLd(stdClass $element) : false|LanguageTaggedString|TypedValue
If the passed value element can't be transformed to a language-tagged string or a typed value false is returned.
Parameters
- $element : stdClass
-
The JSON-LD element
Return values
false|LanguageTaggedString|TypedValue —The parsed object
getType()
Get the type
public
getType() : string
For the sake of simplicity, the type is currently just a Node identifier in the form of a string and not a Node reference. This might be changed in the future.
Return values
string —The type.
getValue()
Get the value
public
getValue() : string
Return values
string —The value.
setType()
Set the type
public
setType(string $type) : self
For the sake of simplicity, the type is currently just a Node identifier in the form of a string and not a Node reference. This might be changed in the future.
Parameters
- $type : string
-
The type.
Tags
Return values
selfsetValue()
Set the value
public
setValue(string $value) : self
Parameters
- $value : string
-
The value.
Tags
Return values
selftoJsonLd()
Convert to expanded and flattened JSON-LD
public
toJsonLd([mixed $useNativeTypes = true ]) : mixed
Parameters
- $useNativeTypes : mixed = true
-
If set to true, native types are used for xsd:integer, xsd:double, and xsd:boolean, otherwise typed strings will be used instead.
Return values
mixed —Returns data which can be serialized by JsonLD::toString() (which is a value of any type other than a resource) to expanded JSON-LD.