public function setListener($event, callable $listener)
    {
        if (!is_string($event) || empty($event)) {
            throw new \InvalidArgumentException('The event name is invalid');
        }

        $this->listeners[$event] = $listener;
    }
public function setListener($event, callable $listener)
    {
        if (!is_string($event) || empty($event)) {
            throw new \InvalidArgumentException('The event name is invalid');
        }

        $this->listeners[$event] = $listener;
    }
public function setListener ( $ event , callable $ listener ) { if ( ! is_string ( $ event ) || empty ( $ event ) ) { throw new \ InvalidArgumentException ( 'The event name is invalid' ) ; } $ this -> listeners [ $ event ] = $ listener ; }
Assigns a listener to the given event.

@param string $event The event to assign the listener to
@param callable $listener The listener to register
@throws \InvalidArgumentException if the event name is invalid.
Assigns a listener to the given event .