You are here

public function EasyRdf_Serialiser_Arc::serialise in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Arc.php \EasyRdf_Serialiser_Arc::serialise()

Serialise an EasyRdf_Graph into RDF format of choice.

Parameters

EasyRdf_Graph $graph An EasyRdf_Graph object.:

string $format The name of the format to convert to.:

array $options:

Return value

string The RDF in the new desired format.

Throws

EasyRdf_Exception

Overrides EasyRdf_Serialiser_RdfPhp::serialise

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Arc.php, line 73

Class

EasyRdf_Serialiser_Arc
Class to serialise RDF using the ARC2 library.

Code

public function serialise($graph, $format, array $options = array()) {
  parent::checkSerialiseParams($graph, $format);
  if (array_key_exists($format, self::$supportedTypes)) {
    $className = self::$supportedTypes[$format];
  }
  else {
    throw new EasyRdf_Exception("EasyRdf_Serialiser_Arc does not support: {$format}");
  }
  $serialiser = ARC2::getSer($className);
  if ($serialiser) {
    return $serialiser
      ->getSerializedIndex(parent::serialise($graph, 'php'));
  }
  else {
    throw new EasyRdf_Exception("ARC2 failed to get a {$className} serialiser.");
  }
}