Constructor for creating a new literal
string $value The value of the literal:
string $lang The natural language of the literal or null (e.g. 'en'):
string $datatype The datatype of the literal or null (e.g. 'xsd:string'):
object EasyRdf_Literal
public function __construct($value, $lang = null, $datatype = null) {
$this->value = $value;
$this->lang = $lang ? $lang : null;
$this->datatype = $datatype ? $datatype : null;
if ($this->datatype) {
if (is_object($this->datatype)) {
// Convert objects to strings
$this->datatype = strval($this->datatype);
}
else {
// Expand shortened URIs (CURIEs)
$this->datatype = EasyRdf_Namespace::expand($this->datatype);
}
// Literals can not have both a language and a datatype
$this->lang = null;
}
else {
// Set the datatype based on the subclass
$class = get_class($this);
if (isset(self::$classMap[$class])) {
$this->datatype = self::$classMap[$class];
$this->lang = null;
}
}
// Cast value to string
settype($this->value, 'string');
}