You are here

public function EasyRdf_Container::offsetSet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Container.php \EasyRdf_Container::offsetSet()

Array Access: set an item at a positon in container using array syntax

Example: $seq[2] = $item;

Warning: creating gaps in the sequence will result in unexpected behavior

File

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

Class

EasyRdf_Container
Sub-class of EasyRdf_Resource that represents an RDF container (rdf:Alt, rdf:Bag and rdf:Seq)

Code

public function offsetSet($offset, $value) {
  if (is_int($offset) and $offset > 0) {
    return $this
      ->set('rdf:_' . $offset, $value);
  }
  elseif (is_null($offset)) {
    return $this
      ->append($value);
  }
  else {
    throw new InvalidArgumentException("Container position must be a positive integer");
  }
}