Skip to content

Commit

Permalink
Added the ability to count registry objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpustulka committed May 8, 2017
1 parent 15a7e6f commit 29af1bc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Core/ObjectRegistry.php
Expand Up @@ -17,6 +17,7 @@
use ArrayIterator;
use Cake\Event\EventDispatcherInterface;
use Cake\Event\EventListenerInterface;
use Countable;
use IteratorAggregate;
use RuntimeException;

Expand All @@ -36,7 +37,7 @@
* @see \Cake\View\HelperRegistry
* @see \Cake\Console\TaskRegistry
*/
abstract class ObjectRegistry implements IteratorAggregate
abstract class ObjectRegistry implements Countable, IteratorAggregate
{

/**
Expand Down Expand Up @@ -358,6 +359,16 @@ public function getIterator()
return new ArrayIterator($this->_loaded);
}

/**
* Returns the number of loaded objects.
*
* @return int
*/
public function count()
{
return count($this->_loaded);
}

/**
* Debug friendly object properties.
*
Expand Down

0 comments on commit 29af1bc

Please sign in to comment.