summaryrefslogtreecommitdiff
path: root/lib/querypath/src/QueryPath/QueryPathIterator.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/querypath/src/QueryPath/QueryPathIterator.php')
-rw-r--r--lib/querypath/src/QueryPath/QueryPathIterator.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/querypath/src/QueryPath/QueryPathIterator.php b/lib/querypath/src/QueryPath/QueryPathIterator.php
new file mode 100644
index 0000000..be2e66f
--- /dev/null
+++ b/lib/querypath/src/QueryPath/QueryPathIterator.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @file
+ *
+ * Utility iterator for QueryPath.
+ */
+namespace QueryPath;
+
+/**
+ * An iterator for QueryPath.
+ *
+ * This provides iterator support for QueryPath. You do not need to construct
+ * a QueryPathIterator. QueryPath does this when its QueryPath::getIterator()
+ * method is called.
+ *
+ * @ingroup querypath_util
+ */
+class QueryPathIterator extends \IteratorIterator {
+ public $options = array();
+ private $qp = NULL;
+
+ public function current() {
+ if (!isset($this->qp)) {
+ $this->qp = \QueryPath::with(parent::current(), NULL, $this->options);
+ }
+ else {
+ $splos = new \SplObjectStorage();
+ $splos->attach(parent::current());
+ $this->qp->setMatches($splos);
+ }
+ return $this->qp;
+ }
+}