From 474a3e1b190e2e3dbc5806350f37d28001c9b222 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 7 Jul 2010 17:05:39 -0300 Subject: Fixing null checking at IsisFieldIterator --- classes/IsisFieldIterator.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/IsisFieldIterator.php b/classes/IsisFieldIterator.php index fb67b65..11ed979 100644 --- a/classes/IsisFieldIterator.php +++ b/classes/IsisFieldIterator.php @@ -53,13 +53,27 @@ class IsisFieldIterator implements Iterator do { ++$this->row; } - while ($this->current() == NULL && $this->valid()); + while ($this->current_null() && $this->has_more_rows()); + } + + /** + * Check if there are more rows. + */ + function has_more_rows() { + return $this->row <= $this->rows; + } + + /** + * Check if the current value is null. + */ + function current_null() { + return $this->current() == NULL; } /** * Check if there is a current element after calls to rewind() or next(). */ function valid() { - return $this->row <= $this->rows; + return $this->has_more_rows() && !$this->current_null(); } } -- cgit v1.2.3