<commit_before><?php

/**
 * Server list manager
 * @package framework
 * @subpackage servers
 */

/**
 * Struct that makes it easy for a module set to manage a list of server connections
 */
trait Hm_Server_List {

    /* list of server connections */
    private static $server_list = array();

    /**
     * Server lists must override this method to connect
     * @param int $id server id
     * @param string $server server hostname or ip
     * @param string $user username for authentication
     * @param string $pass password for authentication
     * @param mixed $cache cached connection data
     * @return bool true on success
     */
    abstract public function service_connect($id, $server, $user, $pass, $cache);

    /**
     * Connect to a server
     * @param int $id server id
     * @param mixed $cache cached server data
     * @param string $user username
     * @param string $pass password
     * @param bool $save_credentials true to save the username and password
     * @return mixed connection object on success, otherwise false
     */
    public static function connect($id, $cache=false, $user=false, $pass=false, $save_credentials=false) {
        if (array_key_exists($id, self::$server_list)) {
            $server = self::$server_list[$id];
            if ($server['object']) {
                return $server['object'];
            }
            else {
                if ((!$user || !$pass) && (!array_key_exists('user', $server) || !array_key_exists('pass', $server))) {
                    return false;<commit_msg>fix declaration<commit_after><?php

/**
 * Server list manager
 * @package framework
 * @subpackage servers
 */

/**
 * Struct that makes it easy for a module set to manage a list of server connections
 */
trait Hm_Server_List {

    /* list of server connections */
    private static $server_list = array();

    /**
     * Server lists must override this method to connect
     * @param int $id server id
     * @param string $server server hostname or ip
     * @param string $user username for authentication
     * @param string $pass password for authentication
     * @param mixed $cache cached connection data
     * @return bool true on success
     */
    abstract public static function service_connect($id, $server, $user, $pass, $cache);

    /**
     * Connect to a server
     * @param int $id server id
     * @param mixed $cache cached server data
     * @param string $user username
     * @param string $pass password
     * @param bool $save_credentials true to save the username and password
     * @return mixed connection object on success, otherwise false
     */
    public static function connect($id, $cache=false, $user=false, $pass=false, $save_credentials=false) {
        if (array_key_exists($id, self::$server_list)) {
            $server = self::$server_list[$id];
            if ($server['object']) {
                return $server['object'];
            }
            else {
                if ((!$user || !$pass) && (!array_key_exists('user', $server) || !array_key_exists('pass', $server))) {
                    return false;
{'fraction_non_alphanumeric': 0.11086190323614226, 'fraction_numerical': 0.0, 'mean_word_length': 2.660023446658851, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1948654', 'n_tokens_mistral': 819, 'n_tokens_neox': 813, 'n_words': 307}