Also implement the Countable interface for full array-like compatibility

This commit is contained in:
Thomas Bruederli 2014-02-07 09:29:11 +01:00
parent c2b87d4ad5
commit 1daa305faa

View file

@ -24,7 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
class kolab_storage_dataset implements Iterator, ArrayAccess class kolab_storage_dataset implements Iterator, ArrayAccess, Countable
{ {
private $cache; // kolab_storage_cache instance to use for fetching data private $cache; // kolab_storage_cache instance to use for fetching data
private $memlimit = 0; private $memlimit = 0;
@ -50,6 +50,14 @@ class kolab_storage_dataset implements Iterator, ArrayAccess
} }
/*** Implement PHP Countable interface ***/
public function count()
{
return count($this->index);
}
/*** Implement PHP ArrayAccess interface ***/ /*** Implement PHP ArrayAccess interface ***/
public function offsetSet($offset, $value) public function offsetSet($offset, $value)