You are here

public static function EasyRdf_Literal::setDatatypeMapping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php \EasyRdf_Literal::setDatatypeMapping()

Register an RDF datatype with a PHP class name

When parsing registered class will be used whenever the datatype is seen.

When serialising a registered class, the mapping will be used to set the datatype in the RDF.

Example: EasyRdf_Literal::registerDatatype('xsd:dateTime', 'My_DateTime_Class');

Parameters

string $datatype The RDF datatype (e.g. xsd:dateTime):

string $class The PHP class name (e.g. My_DateTime_Class):

1 call to EasyRdf_Literal::setDatatypeMapping()
Literal.php in vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php, line 128

Class

EasyRdf_Literal
Class that represents an RDF Literal

Code

public static function setDatatypeMapping($datatype, $class) {
  if (!is_string($datatype) or $datatype == null or $datatype == '') {
    throw new InvalidArgumentException("\$datatype should be a string and cannot be null or empty");
  }
  if (!is_string($class) or $class == null or $class == '') {
    throw new InvalidArgumentException("\$class should be a string and cannot be null or empty");
  }
  $datatype = EasyRdf_Namespace::expand($datatype);
  self::$datatypeMap[$datatype] = $class;
  self::$classMap[$class] = $datatype;
}