Use IteratorAggregate/ArrayIterator.
authorJan Schneider <jan@horde.org>
Fri, 25 Jun 2010 15:23:49 +0000 (17:23 +0200)
committerJan Schneider <jan@horde.org>
Fri, 25 Jun 2010 15:23:49 +0000 (17:23 +0200)
framework/History/lib/Horde/History/Log.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Permission/AclIterator.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Permission/ElementIterator.php

index ca5d47a..be10555 100644 (file)
@@ -11,7 +11,7 @@
  * @author  Jan Schneider <jan@horde.org>
  * @package History
  */
-class Horde_History_Log implements Iterator, ArrayAccess, Countable
+class Horde_History_Log implements IteratorAggregate, ArrayAccess, Countable
 {
     /**
      * TODO
@@ -56,29 +56,9 @@ class Horde_History_Log implements Iterator, ArrayAccess, Countable
         }
     }
 
-    public function current()
+    public function getIterator()
     {
-        return current($this->_data);
-    }
-
-    public function key()
-    {
-        return key($this->_data);
-    }
-
-    public function next()
-    {
-        next($this->_data);
-    }
-
-    public function rewind()
-    {
-        reset($this->_data);
-    }
-
-    public function valid()
-    {
-        return current($this->_data) !== false;
+        return new ArrayIterator($this->_data);
     }
 
     public function offsetExists($offset)
index 38ac8fd..928504b 100644 (file)
@@ -25,8 +25,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Storage
  */
-class Horde_Kolab_Storage_Folder_Permission_AclIterator
-implements Iterator
+class Horde_Kolab_Storage_Folder_Permission_AclIterator implements IteratorAggregate
 {
     /**
      * The ACL elements.
@@ -66,28 +65,8 @@ implements Iterator
         }
     }
 
-    public function rewind()
+    public function getIterator()
     {
-        return reset($this->_acl);
-    }
-
-    public function current()
-    {
-        return current($this->_acl);
-    }
-
-    public function key()
-    {
-        return key($this->_acl);
-    }
-
-    public function next()
-    {
-        return next($this->_acl);
-    }
-
-    public function valid()
-    {
-        return key($this->_acl) !== null;
+        return new ArrayIterator($this->_acl);
     }
 }
index 4b31a5f..fefdce3 100644 (file)
@@ -25,8 +25,7 @@
  * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
  * @link     http://pear.horde.org/index.php?package=Kolab_Storage
  */
-class Horde_Kolab_Storage_Folder_Permission_ElementIterator
-implements Iterator
+class Horde_Kolab_Storage_Folder_Permission_ElementIterator implements IteratorAggregate
 {
     /**
      * The Horde permission elements.
@@ -73,28 +72,8 @@ implements Iterator
         }
     }
 
-    public function rewind()
+    public function getIterator()
     {
-        return reset($this->_elements);
-    }
-
-    public function current()
-    {
-        return current($this->_elements);
-    }
-
-    public function key()
-    {
-        return key($this->_elements);
-    }
-
-    public function next()
-    {
-        return next($this->_elements);
-    }
-
-    public function valid()
-    {
-        return key($this->_elements) !== null;
+        return new ArrayIterator($this->_elements);
     }
 }