/**
  * Injects the event loop of the bot's client into the plugin if it implements
  * \Phergie\Irc\Bot\React\LoopInterface.
  *
  * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin
  * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin
  */
 public function process(PluginInterface $plugin, Bot $bot)
 {
     $client = $bot->getClient();
     if ($plugin instanceof LoopAwareInterface && $client instanceof LoopAccessorInterface) {
         $plugin->setLoop($client->getLoop());
     }
 }
 /**
  * Injects the bot's client into the plugin if it implements
  * \Phergie\Irc\Bot\React\ClientAwareInterface.
  *
  * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin
  * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin
  */
 public function process(PluginInterface $plugin, Bot $bot)
 {
     if ($plugin instanceof ClientAwareInterface) {
         $plugin->setClient($bot->getClient());
     }
 }
 /**
  * Injects the bot's client into the plugin if it implements
  * \Phergie\Irc\Bot\React\ClientAwareInterface.
  *
  * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin
  * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin
  */
 public function process(PluginInterface $plugin, Bot $bot)
 {
     if ($plugin instanceof EventQueueFactoryAwareInterface) {
         $plugin->setEventQueueFactory($bot->getEventQueueFactory());
     }
 }
 /**
  * Injects the bot's logger into the plugin if it implements
  * \Psr\Log\LoggerAwareInterface.
  *
  * @param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin
  * @param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin
  */
 public function process(PluginInterface $plugin, Bot $bot)
 {
     if ($plugin instanceof LoggerAwareInterface) {
         $plugin->setLogger($bot->getLogger());
     }
 }
 /**
  * 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 . '"');
         }
     }
 }