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

getConnections() protected method

Extracts connections from configuration.
protected getConnections ( array $config ) : Phergie\Irc\ConnectionInterface[]
$config array Associative array keyed by setting name
return Phergie\Irc\ConnectionInterface[]
    protected function getConnections(array $config)
    {
        if (!isset($config['connections'])) {
            throw new \RuntimeException('Configuration must contain a "connections" key');
        }
        if (!is_array($config['connections']) || !$config['connections']) {
            throw new \RuntimeException('Configuration "connections" key must reference a non-empty array');
        }
        $connections = array_filter($config['connections'], function ($connection) {
            return $connection instanceof ConnectionInterface;
        });
        if (count($connections) != count($config['connections'])) {
            throw new \RuntimeException('All configuration "connections" array values must implement \\Phergie\\Irc\\ConnectionInterface');
        }
        return $connections;
    }