public function selectConnection(array $connections)
    {
        $weighted = [];

        foreach ($connections as $connection) {
            foreach (range(0, $connection['weight']) as $i) {
                $weighted[] = $connection;
            }
        }

        $index = mt_rand(0, count($weighted) - 1);

        return $weighted[$index];
    }