You are here

protected function EasyRdf_Sparql_Result::newTerm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Result.php \EasyRdf_Sparql_Result::newTerm()

Create a new EasyRdf_Resource or EasyRdf_Literal depending on the type of data passed in.

@ignore

2 calls to EasyRdf_Sparql_Result::newTerm()
EasyRdf_Sparql_Result::parseJson in vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Result.php
Parse a SPARQL result in the JSON format into the object.
EasyRdf_Sparql_Result::parseXml in vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Result.php
Parse a SPARQL result in the XML format into the object.

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Result.php, line 247

Class

EasyRdf_Sparql_Result
Class for returned for SPARQL SELECT and ASK query responses.

Code

protected function newTerm($data) {
  switch ($data['type']) {
    case 'bnode':
      return new EasyRdf_Resource('_:' . $data['value']);
    case 'uri':
      return new EasyRdf_Resource($data['value']);
    case 'literal':
    case 'typed-literal':
      return EasyRdf_Literal::create($data);
    default:
      throw new EasyRdf_Exception("Failed to parse SPARQL Query Results format, unknown term type: " . $data['type']);
  }
}