Horde_Notification_Handler::count PHP Method

count() public method

Return the number of notification messages in the stack.
Author: David Ulevitch ([email protected])
public count ( string $my_listener = null ) : integer
$my_listener string The name of the listener.
return integer The number of messages in the stack.
    public function count($my_listener = null)
    {
        $count = 0;
        if (!is_null($my_listener)) {
            if ($ob = $this->get($my_listener)) {
                $count = count($this->_storage->get($ob->getName()));
                if ($this->_storage->exists('_unattached')) {
                    foreach ($this->_storage->get('_unattached') as $val) {
                        if ($ob->handles($val->type)) {
                            ++$count;
                        }
                    }
                }
            }
        } else {
            if ($this->_storage->exists('_unattached')) {
                $count = count($this->_storage->get('_unattached'));
            }
            foreach ($this->_listeners as $val) {
                if ($this->_storage->exists($val->getName())) {
                    $count += count($this->_storage->get($val->getName()));
                }
            }
        }
        return $count;
    }