You are here

public function EasyRdf_Collection::offsetGet in Zircon Profile 8

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

Array Access: get an item at a specified position in collection using array syntax

Example: $item = $list[2];

File

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

Class

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

Code

public function offsetGet($offset) {
  if (is_int($offset) and $offset > 0) {
    list($node, $position) = $this
      ->getCollectionNode($offset);
    if ($node and $position === $offset) {
      return $node
        ->get('rdf:first');
    }
  }
  else {
    throw new InvalidArgumentException("Collection offset must be a positive integer");
  }
}