public static function EasyRdf_Literal::getDatatypeForValue in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php \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.
2 calls to EasyRdf_Literal::getDatatypeForValue()
- EasyRdf_Graph::checkValueParam in 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 vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal.php - Create a new literal object
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal.php, line 176
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#double';
}
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;
}
}