<commit_before><?php namespace Very\Database;

use PDO;
use PDOException;
use RuntimeException;

class Connection {
    /**
     * @static
     *
     * @param string $db
     *
     * @return MysqlConnection
     */
    static private $instances = array();

    static function getInstances() {
        return self::$instances;
    }

    static public function getInstance($db) {
        if (!isset(self::$instances[$db])) {
            $config = config('db', $db);
            if ($config) {

                try {
                    if ($config['dbtype'] == 'mysql') {
                        $dns = 'mysql:host=' . $config['dbhost'] . ';dbname=' . $config['dbname'];

                        if (isset($config['dbport']) && !empty($config['dbport'])) {
                            $dns .= ';port=' . $config['dbport'];
                        }

                        self::$instances[$db] = new MysqlConnection($dns, $config['dbuser'], $config['dbpswd'], array(
                            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . $config['dbcharset']));
                    }
                    return self::$instances[$db];
                } catch (PDOException $e) {
                    throw new RuntimeException("DB connect error for db $db:" . $e->getMessage());
                }
            } else {
                throw new RuntimeException('DB config error! Please checking dir in config/db.php');
            }
        } else {
            return self::$instances[$db];
        }
    }
}<commit_msg>return tips<commit_after><?php namespace Very\Database;

use PDO;
use PDOException;
use RuntimeException;

class Connection {
    /**
     * @static
     *
     * @param string $db
     *
     * @return MysqlConnection
     */
    static private $instances = array();

    static function getInstances() {
        return self::$instances;
    }

    /**
     * @param $db
     *
     * @return MysqlConnection
     */
    static public function getInstance($db) {
        if (!isset(self::$instances[$db])) {
            $config = config('db', $db);
            if ($config) {

                try {
                    if ($config['dbtype'] == 'mysql') {
                        $dns = 'mysql:host=' . $config['dbhost'] . ';dbname=' . $config['dbname'];

                        if (isset($config['dbport']) && !empty($config['dbport'])) {
                            $dns .= ';port=' . $config['dbport'];
                        }

                        self::$instances[$db] = new MysqlConnection($dns, $config['dbuser'], $config['dbpswd'], array(
                            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . $config['dbcharset']));
                    }
                    return self::$instances[$db];
                } catch (PDOException $e) {
                    throw new RuntimeException("DB connect error for db $db:" . $e->getMessage());
                }
            } else {
                throw new RuntimeException('DB config error! Please checking dir in config/db.php');
            }
        } else {
            return self::$instances[$db];
        }
    }
}
{'fraction_non_alphanumeric': 0.14884763124199743, 'fraction_numerical': 0.0, 'mean_word_length': 1.5468622656886715, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3496288', 'n_tokens_mistral': 861, 'n_tokens_neox': 834, 'n_words': 185}