<commit_before><?php 

namespace Lighty\Kernel\Database\Connector;

use Lighty\Kernel\Objects\Strings;
use Lighty\Kernel\Config\Config;
use PDO;
use PDOException;

/**
* Mysql Connector
*/
class MysqlConnector
{
	/**
	 * Mysql Connector
	 * @param PDO
	 */
	private $connector; 

	/**
	 * Constructor
	 * @param string,string,string,string
	 * @return PDO
	 */
	function __construct($host = null, $database = null, $user = null, $password = null)
	{
		$config = $this->config($host, $database, $user, $password);
		//
		$dsn = "mysql:host=".$config["host"].";dbname=".$config["database"];
		//
		try 
		{
			$this->connector = new PDO(
					$dsn,
					$config["user"],
					$config["password"]
				);
			//
			$this->connector->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		} 
		catch (PDOException $e) 
		{
			throw new ConnectorException;
		}
		//
		return $this->connector;
	}

	/**
	* check if the host is localhost and replace it by adresse
	* @param string
	* @return string
	*/
	protected function setLocal($host)
	{
		return Strings::trim($host) == "localhost" ? "127.0.0.1" : $host;
	}

	/**
	* get Connection configuration
	* @param string,string,string,string
	* @return 
	*/
	protected function config($host, $database, $user, $password)
	{
		//if(Config::get("database.host")=="" && Config::get("database.username")=="" && Config::get("database.password")=="" && Config::get("database.database")=="") throw new DatabaseArgumentsException();
		return [
			"host" => $this->setLocal( $host ? $host : Config::get("database.host")),
			"database" => $database ? $database : Config::get("database.database"),
			"user" => $user ? $user : Config::get("database.username"),
			"password" => $password ? $password : Config::get("database.password"),
		];
	}

	/**
	* Close the Mysql connection
	*/
	public function close()
	{
		$this->connector = null;
	}
	
	


	
}<commit_msg>use ConnectorException namespace<commit_after><?php 

namespace Lighty\Kernel\Database\Connector;

use Lighty\Kernel\Objects\Strings;
use Lighty\Kernel\Config\Config;
use Lighty\Kernel\Database\Connector\Exception\ConnectorException;
use PDO;
use PDOException;


/**
* Mysql Connector
*/
class MysqlConnector
{
	/**
	 * Mysql Connector
	 * @param PDO
	 */
	private $connector; 

	/**
	 * Constructor
	 * @param string,string,string,string
	 * @return PDO
	 */
	function __construct($host = null, $database = null, $user = null, $password = null)
	{
		$config = $this->config($host, $database, $user, $password);
		//
		$dsn = "mysql:host=".$config["host"].";dbname=".$config["database"];
		//
		try 
		{
			$this->connector = new PDO(
					$dsn,
					$config["user"],
					$config["password"]
				);
			//
			$this->connector->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		} 
		catch (PDOException $e) 
		{
			throw new ConnectorException;
		}
		//
		return $this->connector;
	}

	/**
	* check if the host is localhost and replace it by adresse
	* @param string
	* @return string
	*/
	protected function setLocal($host)
	{
		return Strings::trim($host) == "localhost" ? "127.0.0.1" : $host;
	}

	/**
	* get Connection configuration
	* @param string,string,string,string
	* @return 
	*/
	protected function config($host, $database, $user, $password)
	{
		//if(Config::get("database.host")=="" && Config::get("database.username")=="" && Config::get("database.password")=="" && Config::get("database.database")=="") throw new DatabaseArgumentsException();
		return [
			"host" => $this->setLocal( $host ? $host : Config::get("database.host")),
			"database" => $database ? $database : Config::get("database.database"),
			"user" => $user ? $user : Config::get("database.username"),
			"password" => $password ? $password : Config::get("database.password"),
		];
	}

	/**
	* Close the Mysql connection
	*/
	public function close()
	{
		$this->connector = null;
	}
	
	


	
}
{'fraction_non_alphanumeric': 0.18622646376063967, 'fraction_numerical': 0.003095176683002321, 'mean_word_length': 3.8902900378310212, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5384431', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1289, 'n_words': 260}