<commit_before><?php
/**
 * @package   Gears\Framework
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2011-2013 <NAME> <<EMAIL>>
 * @license   http://url/license
 */
namespace Gears\Framework\Db;

use Gears\Framework\Db\Adapter\Generic;

/**
 * Database abstraction layer class. Factory for the specific database adaptors
 * @package    Gears\Framework
 * @subpackage Database
 */
class Db
{
    /**
     * Database adapter instance holder
     * @var Generic
     */
    private static $adapter;

    /**
     * Create database connection using the given connection parameters
     * @param string $host
     * @param string $user
     * @param string $pass
     * @param string $dbname
     * @param string $driver
     * @return Generic
     */
    public static function connect($host, $user, $pass, $dbname, $driver = 'mysql')
    {
        $className = __NAMESPACE__ . '\\Adapter\\' . ucfirst(strtolower($driver));
        self::$adapter = new $className($host, $user, $pass, $dbname, $driver);
        return self::$adapter;
    }

    /**
     * Get database connection adapter
     * @return Generic
     */
    public static function getAdapter()
    {
        if (null == self::$adapter) {
            throw new \Exception(__CLASS__ . ': no database adapter set. Please check that db connection was successfully established');
        }
        return self::$adapter;
    }
}<commit_msg>Improved App component: - use Config instance instead of static calls - app initialization split into few methods - app now requires main application config file on construction - app services initialization moved into init() method, which is called automatically on run() and also can be called manually - app config is now accessible from outside of app with getConfig() methods, thus various app initialization parameters can be changed before its run/init<commit_after><?php
/**
 * @package   Gears\Framework
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2011-2013 <NAME> <<EMAIL>>
 * @license   http://url/license
 */
namespace Gears\Framework\Db;

use Gears\Framework\Db\Adapter\Generic;

/**
 * Database abstraction layer class. Factory for the specific database adaptors
 * @package    Gears\Framework
 * @subpackage Database
 */
class Db
{
    /**
     * Database adapter instance holder
     * @var Generic
     */
    private static $adapter;

    /**
     * Create database connection using the given connection parameters
     * @param string $host
     * @param string $user
     * @param string $pass
     * @param string $dbname
     * @param string $driver
     * @return Generic
     */
    public static function connect($host, $user, $pass, $dbname, $driver)
    {
        $className = __NAMESPACE__ . '\\Adapter\\' . ucfirst(strtolower($driver));
        self::$adapter = new $className($host, $user, $pass, $dbname, $driver);
        return self::$adapter;
    }

    /**
     * Get database connection adapter
     * @return Generic
     */
    public static function getAdapter()
    {
        if (null == self::$adapter) {
            throw new \Exception('No database adapter set. Please check that db connection was successfully established');
        }
        return self::$adapter;
    }
}
{'fraction_non_alphanumeric': 0.11412708204811844, 'fraction_numerical': 0.004935225169648365, 'mean_word_length': 2.8242924528301887, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '2685475', 'n_tokens_mistral': 869, 'n_tokens_neox': 851, 'n_words': 304}