public function add($listener, $priority)
    {
        if (!$this->storage->contains($listener)) {
            // Compute the internal priority as an array.
            $priority = [$priority, $this->counter--];

            $this->storage->attach($listener, $priority);
            $this->queue->insert($listener, $priority);
        }

        return $this;
    }
public function add($listener, $priority)
    {
        if (!$this->storage->contains($listener)) {
            // Compute the internal priority as an array.
            $priority = [$priority, $this->counter--];

            $this->storage->attach($listener, $priority);
            $this->queue->insert($listener, $priority);
        }

        return $this;
    }
public function add ( $ listener , $ priority ) { if ( ! $ this -> storage -> contains ( $ listener ) ) { // Compute the internal priority as an array. $ priority = [ $ priority , $ this -> counter -- ] ; $ this -> storage -> attach ( $ listener , $ priority ) ; $ this -> queue -> insert ( $ listener , $ priority ) ; } return $ this ; }
Add a listener with the given priority only if not already present.

@param   \Closure|object $listener The listener.
@param   integer         $priority The listener priority.

@return  ListenersQueue  This method is chainable.

@since   2.0
Add a listener with the given priority only if not already present .