You are here

public function EasyRdf_Collection::append in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Collection.php \EasyRdf_Collection::append()

Append an item to the end of the collection

Parameters

mixed $value The value to append:

Return value

integer The number of values appended (1 or 0)

1 call to EasyRdf_Collection::append()
EasyRdf_Collection::offsetSet in vendor/easyrdf/easyrdf/lib/EasyRdf/Collection.php
Array Access: set an item at a positon in collection using array syntax

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Collection.php, line 200

Class

EasyRdf_Collection
Sub-class of EasyRdf_Resource that represents an RDF collection (rdf:List)

Code

public function append($value) {

  // Find the end of the collection
  list($node, $position) = $this
    ->getCollectionNode(null);
  $rest = $node
    ->get('rdf:rest');
  if ($node === $this and is_null($rest)) {
    $node
      ->set('rdf:first', $value);
    $node
      ->addResource('rdf:rest', 'rdf:nil');
  }
  else {
    $new = $this->graph
      ->newBnode();
    $node
      ->set('rdf:rest', $new);
    $new
      ->add('rdf:first', $value);
    $new
      ->addResource('rdf:rest', 'rdf:nil');
  }
  return 1;
}