public static function EasyRdf_Literal::getDatatypeForValue

Get datatype URI for a PHP value.

This static function is intended for internal use. Given a PHP value, it will return an XSD datatype URI for that value, for example: http://www.w3.org/2001/XMLSchema#integer

Return value

string A URI for the datatype of $value.

3 calls to EasyRdf_Literal::getDatatypeForValue()
EasyRdf_Graph::addLiteral in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add a literal value as a property of a resource
EasyRdf_Graph::checkValueParam in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Check that a value parameter is valid, and convert it to an associative array if needed @ignore
EasyRdf_Literal::create in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php
Create a new literal object

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php, line 177

Class

EasyRdf_Literal
Class that represents an RDF Literal

Code

public static function getDatatypeForValue($value) {
  if (is_float($value)) {
    return 'http://www.w3.org/2001/XMLSchema#decimal';
  }
  elseif (is_int($value)) {
    return 'http://www.w3.org/2001/XMLSchema#integer';
  }
  elseif (is_bool($value)) {
    return 'http://www.w3.org/2001/XMLSchema#boolean';
  }
  elseif (is_object($value) and $value instanceof DateTime) {
    return 'http://www.w3.org/2001/XMLSchema#dateTime';
  }
  else {
    return null;
  }
}