public function on($event, $handler, $prepend = false)
   {
      if (!is_string($event)) {
         throw new InvalidArgumentException(
            "invalid value provided for 'event'; ".
            "expecting an event name as string"
         );
      }

      $handler = new Handler($event, $handler);
      if ($prepend === false) {
         $this->eventHandlers[] = $handler;
      }
      else {
         array_unshift($this->eventHandlers, $handler);
      }

      return $this;
   }
public function on($event, $handler, $prepend = false)
   {
      if (!is_string($event)) {
         throw new InvalidArgumentException(
            "invalid value provided for 'event'; ".
            "expecting an event name as string"
         );
      }

      $handler = new Handler($event, $handler);
      if ($prepend === false) {
         $this->eventHandlers[] = $handler;
      }
      else {
         array_unshift($this->eventHandlers, $handler);
      }

      return $this;
   }
public function on ( $ event , $ handler , $ prepend = false ) { if ( ! is_string ( $ event ) ) { throw new InvalidArgumentException ( "invalid value provided for 'event'; " . "expecting an event name as string" ) ; } $ handler = new Handler ( $ event , $ handler ) ; if ( $ prepend === false ) { $ this -> eventHandlers [ ] = $ handler ; } else { array_unshift ( $ this -> eventHandlers , $ handler ) ; } return $ this ; }
Add an event handler

@param string $event The name of the event
@param string|callable $handler The function that handles the event
@param boolean $prepend Add the handler at the top of the stack
@return sndsgd\event\Target
@throws InvalidArgumentException If the event isn't a string
Add an event handler