public function EasyRdf_Literal::__construct in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php \EasyRdf_Literal::__construct()
Constructor for creating a new literal
Parameters
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'):
Return value
object EasyRdf_Literal
8 calls to EasyRdf_Literal::__construct()
- EasyRdf_Literal_Boolean::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Boolean.php - Constructor for creating a new boolean literal
- EasyRdf_Literal_Date::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Date.php - Constructor for creating a new date literal
- EasyRdf_Literal_DateTime::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ DateTime.php - Constructor for creating a new date and time literal
- EasyRdf_Literal_Decimal::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Decimal.php - Constructor for creating a new decimal literal
- EasyRdf_Literal_HexBinary::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ HexBinary.php - Constructor for creating a new xsd:hexBinary literal
7 methods override EasyRdf_Literal::__construct()
- EasyRdf_Literal_Boolean::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Boolean.php - Constructor for creating a new boolean literal
- EasyRdf_Literal_Date::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Date.php - Constructor for creating a new date literal
- EasyRdf_Literal_Decimal::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ Decimal.php - Constructor for creating a new decimal literal
- EasyRdf_Literal_HexBinary::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ HexBinary.php - Constructor for creating a new xsd:hexBinary literal
- EasyRdf_Literal_HTML::__construct in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ HTML.php - Constructor for creating a new rdf:HTML literal
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal.php, line 200
Class
- EasyRdf_Literal
- Class that represents an RDF Literal
Code
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;
}
}
if (is_float($this->value)) {
// special handling of floats, as they suffer from locale [mis]configuration
$this->value = rtrim(sprintf('%F', $this->value), '0');
}
else {
// Cast value to string
settype($this->value, 'string');
}
}