diff --git a/src/Object/AbstractCollection.php b/src/Object/AbstractCollection.php index c55e688c..0592bdfd 100644 --- a/src/Object/AbstractCollection.php +++ b/src/Object/AbstractCollection.php @@ -36,6 +36,7 @@ namespace Nosto\Object; +use Countable; use Iterator; /** @@ -43,7 +44,7 @@ * functionality to validate the items added to the collection. The collection behaves * like an array. making it easy to add items to it and iterate over it. */ -abstract class AbstractCollection implements Iterator +abstract class AbstractCollection implements Iterator, Countable { protected $var = array(); @@ -80,6 +81,14 @@ public function next() return next($this->var); } + /** + * @see Iterator::next() + */ + public function count() + { + return count($this->var); + } + /** * @see Iterator::valid() */