You are here

public function EasyRdf_Literal_Decimal::__construct in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php \EasyRdf_Literal_Decimal::__construct()

Constructor for creating a new decimal literal

Parameters

double|int|string $value The value of the literal:

string $lang Should be null (literals with a datatype can't have a language):

string $datatype Optional datatype (default 'xsd:decimal'):

Return value

EasyRdf_Literal_Decimal

Throws

UnexpectedValueException

Overrides EasyRdf_Literal::__construct

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php, line 62

Class

EasyRdf_Literal_Decimal
Class that represents an RDF Literal of datatype xsd:decimal

Code

public function __construct($value, $lang = null, $datatype = null) {
  if (is_string($value)) {
    self::validate($value);
  }
  elseif (is_double($value) or is_int($value)) {
    $locale_data = localeconv();
    $value = str_replace($locale_data['decimal_point'], '.', strval($value));
  }
  else {
    throw new UnexpectedValueException('EasyRdf_Literal_Decimal expects int/float/string as value');
  }
  $value = self::canonicalise($value);
  parent::__construct($value, null, $datatype);
}