/**
  * Validates a plugin's event callbacks.
  *
  * @param \Phergie\Irc\Bot\React\PluginInterface $plugin
  * @throws \RuntimeException if any event callback is invalid
  */
 protected function validatePluginEvents(PluginInterface $plugin)
 {
     $events = $plugin->getSubscribedEvents();
     if (!is_array($events)) {
         throw new \RuntimeException('Plugin of class ' . get_class($plugin) . ' has getSubscribedEvents() implementation' . ' that does not return an array');
     }
     foreach ($events as $event => $callback) {
         if (!is_string($event) || !is_callable([$plugin, $callback]) && !is_callable($callback)) {
             throw new \RuntimeException('Plugin of class ' . get_class($plugin) . ' returns non-string event name or invalid callback' . ' for event "' . $event . '"');
         }
     }
 }