<commit_before><?php
/**
 * Database
 *
 * @uses https://github.com/illuminate/database
 */

namespace Cocoon\Components;
use \Cocoon\Patterns\Singleton;
use \Illuminate\Database\Capsule\Manager as Capsule;

/**
 * Database class
 */
class Database {

  use Singleton;

  /**
   * Store Database Object
   * @var MySqlConnection
   */
  private $db,
          $database;

  static $prefix;

  /**
   * Initialize the Db Object and open the connection
   */
  function init () {

    $database = new Capsule;

    $database->addConnection([
      'driver'    => 'mysql',
      'host'      => DB_HOST,
      'database'  => DB_NAME,
      'username'  => DB_USER,
      'password'  => <PASSWORD>,
      'charset'   => 'utf8',
      'collation' => 'utf8_unicode_ci',
      'prefix'    => self::$prefix
    ], 'default');

    $database->bootEloquent();

    $this->db = $database;

    $this->database = $database->getConnection();

  }

  /**
   * Return a table Object
   * @param  String $table Table name
   * @return Illuminate\Database\Query\Builder
   */
  static function table ($table) {
    return(self::getDb()->table($table));
  }

  /**
   * Get the opened DB Object
   * @return MySqlConnection
   */
  static function getDb() {
    return self::instance()->database;
  }

  /**
   * Get the opened DB Object
   * @return MySqlConnection
   */
  static function schema() {
    return self::getDb()->getSchemaBuilder();
  }

  /**
   * Set the db prefix
   * MUST be called in start.php to initialize the DB also
   * @param String  $prefix Database Prefix 
   */
  static function setPrefix ($prefix) {
    self::$prefix = $prefix;
    self::instance();
  }

  /**
   * Get the db default prefix
   * @return String Default prefix
   */<commit_msg>Added method to retrieve the ConnectionResolverInterface<commit_after><?php
/**
 * Database
 *
 * @uses https://github.com/illuminate/database
 */

namespace Cocoon\Components;
use \Cocoon\Patterns\Singleton;
use \Illuminate\Database\Capsule\Manager as Capsule;

/**
 * Database class
 */
class Database {

  use Singleton;

  /**
   * Store Database Object
   * @var MySqlConnection
   */
  private $db,
          $connection;

  static $prefix;

  /**
   * Initialize the Db Object and open the connection
   */
  function init () {

    $database = new Capsule;

    $database->addConnection([
      'driver'    => 'mysql',
      'host'      => DB_HOST,
      'database'  => DB_NAME,
      'username'  => DB_USER,
      'password'  => <PASSWORD>,
      'charset'   => 'utf8',
      'collation' => 'utf8_unicode_ci',
      'prefix'    => self::$prefix
    ], 'default');

    $database->bootEloquent();

    $this->db = $database;
    $this->connection = $database->getConnection();

  }

  /**
   * Get the opened DB Object
   * @return MySqlConnection
   */
  static function getDb() {
    return self::instance()->connection;
  }

  /**
   * Get the opened DB Object
   * @return MySqlConnection
   */
  static function schema() {
    return self::getDb()->getSchemaBuilder();
  }

  /**
   * Get the database manager
   * @return  Illuminate\Database\ConnectionResolverInterface Database Manager
   */
  static function getDatabaseManager() {
    return self::instance()->db->getDatabaseManager();
  }

  /**
   * Set the db prefix
   * MUST be called in start.php to initialize the DB also
   * @param String  $prefix Database Prefix 
   */
  static function setPrefix ($prefix) {
    self::$prefix = $prefix;
    self::instance();
  }

  /**
   * Get the db default prefix
   * @return String Default prefix
   */
{'fraction_non_alphanumeric': 0.14086081609837897, 'fraction_numerical': 0.0011179429849077697, 'mean_word_length': 2.6371951219512195, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 38, 'https://': 2, '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': '496175', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1091, 'n_words': 280}