Phergie\Irc\Bot\React\Bot::validatePluginEvents PHP Method

validatePluginEvents() protected method

Validates a plugin's event callbacks.
protected validatePluginEvents ( Phergie\Irc\Bot\React\PluginInterface $plugin )
$plugin Phergie\Irc\Bot\React\PluginInterface
    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 . '"');
            }
        }
    }