You are here

protected function EasyRdf_Serialiser_Turtle::serialiseCollection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php \EasyRdf_Serialiser_Turtle::serialiseCollection()

Protected method to serialise a RDF collection @ignore

1 call to EasyRdf_Serialiser_Turtle::serialiseCollection()
EasyRdf_Serialiser_Turtle::serialiseProperties in vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php
Protected method to serialise the properties of a resource @ignore

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php, line 171

Class

EasyRdf_Serialiser_Turtle
Class to serialise an EasyRdf_Graph to Turtle with no external dependancies.

Code

protected function serialiseCollection($node, $indent) {
  $turtle = '(';
  $count = 0;
  while ($node) {
    if ($id = $node
      ->getBNodeId()) {
      $this->outputtedBnodes[$id] = true;
    }
    $value = $node
      ->get('rdf:first');
    $node = $node
      ->get('rdf:rest');
    if ($node and $node
      ->hasProperty('rdf:first')) {
      $count++;
    }
    if ($value !== null) {
      $serialised = $this
        ->serialiseObject($value);
      if ($count) {
        $turtle .= "\n{$indent}  {$serialised}";
      }
      else {
        $turtle .= " " . $serialised;
      }
    }
  }
  if ($count) {
    $turtle .= "\n{$indent})";
  }
  else {
    $turtle .= " )";
  }
  return $turtle;
}