public function EasyRdf_Literal_HexBinary::__construct in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/HexBinary.php \EasyRdf_Literal_HexBinary::__construct()
Constructor for creating a new xsd:hexBinary literal
Parameters
mixed $value The value of the literal (already encoded as hexadecimal):
string $lang Should be null (literals with a datatype can't have a language):
string $datatype Optional datatype (default 'xsd:hexBinary'):
Return value
object EasyRdf_Literal_HexBinary
Overrides EasyRdf_Literal::__construct
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Literal/ HexBinary.php, line 55
Class
- EasyRdf_Literal_HexBinary
- Class that represents an RDF Literal of datatype xsd:hexBinary
Code
public function __construct($value, $lang = null, $datatype = null) {
// Normalise the canonical representation, as specified here:
// http://www.w3.org/TR/xmlschema-2/#hexBinary-canonical-repr
$value = strtoupper($value);
// Validate the data
if (preg_match('/[^A-F0-9]/', $value)) {
throw new InvalidArgumentException("Literal of type xsd:hexBinary contains non-hexadecimal characters");
}
parent::__construct(strtoupper($value), null, 'xsd:hexBinary');
}