<?php
namespace App\Models;
use PDO;
class DatabaseConnection{
    private static $connection = null;
    private function __construct(){
        $config = CONFIG['database'];
        self::$connection = new PDO("mysql:host=". $config['host'] .";dbname=" . $config['database'] . "", $config['user'], $config['pass']);
    }
    public static function getConnection(){
        if(self::$connection){
            return self::$connection;
        }
        $dbConnection = new DatabaseConnection();
        return $dbConnection::getConnection();
    }
}