LanguageTaggedString
extends Value
in package
A LanguageTaggedString is a string which is tagged with a language.
Tags
Table of Contents
Properties
- $value : string
- The value in the form of a string
- $language : string
- The language code associated with the string. Language codes are tags according to {@link http://tools.ietf.org/html/bcp47 BCP47}.
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
- getLanguage() : string
- Get the language
- getValue() : string
- Get the value
- setLanguage() : self
- Set the language
- 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
$language
The language code associated with the string. Language codes are tags according to {@link http://tools.ietf.org/html/bcp47 BCP47}.
private
string
$language
Methods
__construct()
Constructor
public
__construct(string $value, string $language) : mixed
Parameters
- $value : string
-
The string's value.
- $language : string
-
The string's language.
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
getLanguage()
Get the language
public
getLanguage() : string
Return values
string —The language.
getValue()
Get the value
public
getValue() : string
Return values
string —The value.
setLanguage()
Set the language
public
setLanguage(string $language) : self
Parameters
- $language : string
-
The language.
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.