You are here

public function EasyRdf_Collection::count in Zircon Profile 8

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

Counts the number of items in the collection

Note that this is an slow method - it is more efficient to use the iterator interface, if you can.

Return value

integer The number of items in the collection

File

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

Class

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

Code

public function count() {

  // Find the end of the collection
  list($node, $position) = $this
    ->getCollectionNode(null);
  if (!$node
    ->hasProperty('rdf:first')) {
    return 0;
  }
  else {
    return $position;
  }
}