Skip to content

Commit

Permalink
padronizando pacote com o original
Browse files Browse the repository at this point in the history
  • Loading branch information
walisson-interaktiv committed Sep 23, 2022
1 parent 02204d9 commit cee571b
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/Connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,13 @@ class Connect
/** @var PDOException|null */
private static ?PDOException $error = null;

private const CONFIG = [
'driver' => getenv('DBDRIVER'),
'host' => getenv('DBHOST'),
'port' => getenv('DBPORT'),
'dbname' => getenv('DBNAME'),
'username' => getenv('DBUSER'),
'passwd' => getenv('DBPASS'),
'options' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
PDO::ATTR_CASE => PDO::CASE_NATURAL
]
];

/**
* @param array|null $database
* @return PDO|null
*/
public static function getInstance(array $database = null): ?PDO
{
$dbConf = $database ?? self::CONFIG;
$dbConf = $database ?? DATA_LAYER_CONFIG;
$dbName = "{$dbConf["driver"]}-{$dbConf["dbname"]}@{$dbConf["host"]}";

if (empty(self::$instance[$dbName])) {
Expand Down

0 comments on commit cee571b

Please sign in to comment.