<commit_before><?php
namespace zeus\database;

use zeus\database\exception\DbCofigNotFoundException;
use zeus\database\pdo\Pdo;
use zeus\database\pdo\XaPdo;
use zeus\sandbox\ConfigManager;

class DbManager
{
	/**
	 * \zeus\database\pdo\Pdo
	 * @var array
	 */
	protected static $driver_instances = [];
	
	/**
	 * \zeus\database\pdo\XaPdo
	 * @var array
	 */
	protected static $xa_driver_instances = [];
	
	/**
	 * 
	 * @param string $database
	 * @return \zeus\database\pdo\Pdo
	 */
	public static function openSession($database = "database")
	{
		if( !isset(self::$driver_instances[$database]) )
		{
			$config = ConfigManager::config($database);
            if(empty($config)){
                throw new DbCofigNotFoundException("Pdo {$database} 配置文件找不到.");
            }

            $cfg = [
                "dsn" => $config["{$database}.pdo.dsn"],
                "user" => $config["{$database}.pdo.user"],
                "pass" => $config["{$database}.pdo.pass"],
                "charset" => $config["{$database}.pdo.charset"],
            ];

			self::$driver_instances[$database] = new Pdo($cfg);
		}
		
		return self::$driver_instances[$database];
	}
	
	/**
	 * 
	 * @param string $xa_database
	 * @return \zeus\database\pdo\XaPdo
	 */
	public static function openXaSession($xa_database)
	{
        if( !isset(self::$xa_driver_instances[$xa_database]) )
        {
            $config = ConfigManager::config($xa_database);
            if(empty($config)){
                throw new DbCofigNotFoundException("Pdo {$xa_database} 配置文件找不到.");
            }

            $cfg = [
                "dsn" => $config["{$xa_database}.pdo.dsn"],
                "user" => $config["{$xa_database}.pdo.user"],
                "pass" => $config["{$xa_database}.pdo.pass"],
                "charset" => $config["{$xa_database}.pdo.charset"],
            ];

            self::$xa_driver_instances[$xa_database] = new XaPdo($cfg);
        }

		return self::$driver_instances[$xa_database];
	}
	
	public static function getAllSessions()
	{
		return self::$driver_instances;
	}
	
	public static function getAllXaSessions()
	{
		return self::$xa_driver_instances;
	}
}<commit_msg>format<commit_after><?php

namespace zeus\database;

use zeus\database\exception\DbCofigNotFoundException;
use zeus\database\pdo\Pdo;
use zeus\database\pdo\XaPdo;
use zeus\sandbox\ConfigManager;

class DbManager
{
    /**
     * \zeus\database\pdo\Pdo
     * @var array
     */
    protected static $driver_instances = [];

    /**
     * \zeus\database\pdo\XaPdo
     * @var array
     */
    protected static $xa_driver_instances = [];

    /**
     *
     * @param string $database
     * @return \zeus\database\pdo\Pdo
     */
    public static function openSession($database = "database")
    {
        if (!isset(self::$driver_instances[$database])) {
            $config = ConfigManager::config($database);
            if (empty($config)) {
                throw new DbCofigNotFoundException("Pdo {$database} 配置文件找不到.");
            }

            $cfg = [
                "dsn" => $config["{$database}.pdo.dsn"],
                "user" => $config["{$database}.pdo.user"],
                "pass" => $config["{$database}.pdo.pass"],
                "charset" => $config["{$database}.pdo.charset"],
            ];

            self::$driver_instances[$database] = new Pdo($cfg);
        }

        return self::$driver_instances[$database];
    }

    /**
     *
     * @param string $xa_database
     * @return \zeus\database\pdo\XaPdo
     */
    public static function openXaSession($xa_database)
    {
        if (!isset(self::$xa_driver_instances[$xa_database])) {
            $config = ConfigManager::config($xa_database);
            if (empty($config)) {
                throw new DbCofigNotFoundException("Pdo {$xa_database} 配置文件找不到.");
            }

            $cfg = [
                "dsn" => $config["{$xa_database}.pdo.dsn"],
                "user" => $config["{$xa_database}.pdo.user"],
                "pass" => $config["{$xa_database}.pdo.pass"],
                "charset" => $config["{$xa_database}.pdo.charset"],
            ];

            self::$xa_driver_instances[$xa_database] = new XaPdo($cfg);
        }

        return self::$driver_instances[$xa_database];
    }

    public static function getAllSessions()
    {
        return self::$driver_instances;
    }

    public static function getAllXaSessions()
    {
        return self::$xa_driver_instances;
    }
}
{'fraction_non_alphanumeric': 0.15976728574625196, 'fraction_numerical': 0.0, 'mean_word_length': 2.308660251665433, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '4411956', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1408, 'n_words': 210}