Implement Countable and Iterator interfaces for Horde_Variables::.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 7 Oct 2010 06:07:55 +0000 (00:07 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 7 Oct 2010 06:45:40 +0000 (00:45 -0600)
framework/Util/lib/Horde/Variables.php

index 97b739f..68da55f 100644 (file)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @package  Util
  */
-class Horde_Variables
+class Horde_Variables implements Countable, Iterator
 {
     /**
      * Array of form variables.
@@ -87,16 +87,6 @@ class Horde_Variables
     }
 
     /**
-     * Return the number of form variables.
-     *
-     * @return integer  The count of variables.
-     */
-    public function count()
-    {
-        return count($this->_vars);
-    }
-
-    /**
      * Alias of isset().
      *
      * @param string $varname  The form variable name.
@@ -323,4 +313,40 @@ class Horde_Variables
         return !is_null($value);
     }
 
+    /* Countable methods. */
+
+    /**
+     */
+    public function count()
+    {
+        return count($this->_vars);
+    }
+
+    /* Iterator methods. */
+
+    public function current()
+    {
+        return current($this->_vars);
+    }
+
+    public function key()
+    {
+        return key($this->_vars);
+    }
+
+    public function next()
+    {
+        next($this->_vars);
+    }
+
+    public function rewind()
+    {
+        reset($this->_vars);
+    }
+
+    public function valid()
+    {
+        return (key($this->_vars) !== null);
+    }
+
 }