<commit_before><?php

/**
 * MySQL
 * @author <NAME><<EMAIL>>
 */

namespace Rapid\Authorization\Database;

use \PDO;

class MySQL
{

    /**
     * @var PDO
     */
    private $conn;

    /**
     * @return PDO
     */
    public function getHandler()
    {
        return $this->conn;
    }

    /**
     * @var MySQL
     */
    private static $instance;

    /**
     * @return MySQL
     */
    public static function instance()
    {
        if(self::$instance instanceof MySQL) {
            return self::$instance;
        } else {
            return self::$instance = new self();
        }
    }

    private function __construct()
    {

    }

    public function connect(Array $connection)
    {
        try {
            $this->conn = new PDO(
                "mysql:host=" . $connection['host'] .
                ';port=' . $connection['port'] .
                ';dbname=' . $connection['dbName'], $connection['user'], $connection['pass']
            );
            $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
            $this->conn->query('SET NAMES ' . $connection['dbCharset']);
            $this->conn->query('SET CHARACTER SET ' . $connection['dbCharset']);
        } catch(PDOException $e) {
            self::showException($e);
        }
    }

    public static function showException($e)
    {
        echo '<pre>';
        echo '<b>' . $e->getMessage() . '</b><br/><br/>';
        echo $e->getTraceAsString();
        echo '</pre>';
    }
<commit_msg>Adicionado método para mostra Exceptions<commit_after><?php

/**
 * MySQL
 * @author <NAME><<EMAIL>>
 */

namespace Rapid\Authorization\Database;

use \PDO;

class MySQL
{

    /**
     * @var PDO
     */
    private $conn;

    /**
     * @return PDO
     */
    public function getHandler()
    {
        return $this->conn;
    }

    /**
     * @var MySQL
     */
    private static $instance;

    /**
     * @return MySQL
     */
    public static function instance()
    {
        if(self::$instance instanceof MySQL) {
            return self::$instance;
        } else {
            return self::$instance = new self();
        }
    }

    private function __construct()
    {

    }

    public function connect(Array $connection)
    {
        try {
            $this->conn = new PDO(
                "mysql:host=" . $connection['host'] .
                ";port=" . $connection['port'] .
                ";dbname=" . $connection['dbName'], $connection['user'], $connection['pass']
            );
            $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->conn->query('SET NAMES ' . $connection['dbCharset']);
            $this->conn->query('SET CHARACTER SET ' . $connection['dbCharset']);
        } catch(PDOException $e) {
            self::showException($e);
        }
    }

    public static function showException($e)
    {
        echo '<pre>';
        echo '<b>' . $e->getMessage() . '</b><br/><br/>';
        echo $e->getTraceAsString();
        echo '</pre>';
    }

{'fraction_non_alphanumeric': 0.16633663366336635, 'fraction_numerical': 0.0, 'mean_word_length': 1.778185151237397, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 41, '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': '186393', 'n_tokens_mistral': 922, 'n_tokens_neox': 894, 'n_words': 178}