From 4263906bee5e85ad067f9f752c5698ccdcc13d67 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 7 Jul 2010 12:17:34 -0300 Subject: Adding IsisFieldIterator --- classes/IsisFieldIterator.php | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 classes/IsisFieldIterator.php (limited to 'classes') diff --git a/classes/IsisFieldIterator.php b/classes/IsisFieldIterator.php new file mode 100644 index 0000000..fb67b65 --- /dev/null +++ b/classes/IsisFieldIterator.php @@ -0,0 +1,65 @@ +rows = $class->getRows($field); + $this->valueset = $class->getValues($field); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + $this->value = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->valueset[$this->row]['field']; + } + + /** + * Move forward to next element. + */ + function next() { + do { + ++$this->row; + } + while ($this->current() == NULL && $this->valid()); + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->row <= $this->rows; + } +} -- cgit v1.2.3