<?php

namespace lib\Core\Database;

use lib\Database\Core\QueryBuilder;
use PDO;

class DB
{
  private static ?PDO $pdo = null;

  public static function init(): void {}

  public static function getPDO(): PDO
  {
    if (self::$pdo === null) {
      $dsn     = sprintf("%s:host=%s;dbname=%s;charset=%s", DATABASE_DRIVER, DATABASE_HOST, DATABASE_DB, DATABASE_CHARSET);
      self::$pdo = new \PDO($dsn, DATABASE_ID, DATABASE_PASSWORD);
      self::$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    }
    return self::$pdo;
  }
}
