You are here

class EasyRdf_Serialiser_Arc 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

Class to serialise RDF using the ARC2 library.

@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php

Hierarchy

Expanded class hierarchy of EasyRdf_Serialiser_Arc

File

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

View source
class EasyRdf_Serialiser_Arc extends EasyRdf_Serialiser_RdfPhp {
  private static $supportedTypes = array(
    'rdfxml' => 'RDFXML',
    'turtle' => 'Turtle',
    'ntriples' => 'NTriples',
    'posh' => 'POSHRDF',
  );

  /**
   * Constructor
   *
   * @return object EasyRdf_Serialiser_Arc
   */
  public function __construct() {
    require_once 'arc/ARC2.php';
  }

  /**
   * Serialise an EasyRdf_Graph into RDF format of choice.
   *
   * @param EasyRdf_Graph $graph   An EasyRdf_Graph object.
   * @param string        $format  The name of the format to convert to.
   * @param array         $options
   * @throws EasyRdf_Exception
   * @return string              The RDF in the new desired format.
   */
  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.");
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EasyRdf_Serialiser::$prefixes protected property
EasyRdf_Serialiser::addPrefix protected function Keep track of the prefixes used while serialising @ignore
EasyRdf_Serialiser::checkSerialiseParams protected function Check and cleanup parameters passed to serialise() method @ignore
EasyRdf_Serialiser::reversePropertyCount protected function Protected method to get the number of reverse properties for a resource If a resource only has a single property, the number of values for that property is returned instead. @ignore
EasyRdf_Serialiser_Arc::$supportedTypes private static property
EasyRdf_Serialiser_Arc::serialise public function Serialise an EasyRdf_Graph into RDF format of choice. Overrides EasyRdf_Serialiser_RdfPhp::serialise
EasyRdf_Serialiser_Arc::__construct public function Constructor Overrides EasyRdf_Serialiser::__construct