v-wordpress-plugin-updater/v-update-api/app/Core/DatabaseManager.php
Nikolai X. Shadeauxs 8fc3bc20ad
Some checks failed
CI & Security / CI Scan (push) Failing after 9s
CI & Security / CodeQL (JavaScript) (push) Failing after 6s
CI & Security / Semgrep (PHP) (push) Failing after 8s
modified: .github/copilot-instructions.md
modified:   CHANGELOG.md
	modified:   README.md
2026-04-06 14:39:21 -04:00

48 lines
1.1 KiB
PHP

<?php
// phpcs:ignoreFile PSR1.Files.SideEffects.FoundWithSymbols
/**
* Project: UpdateAPI
* Author: Vontainment <services@vontainment.com>
* License: https://opensource.org/licenses/MIT MIT License
* Link: https://vontainment.com
* Version: 4.5.0
*
* File: DatabaseManager.php
* Description: WordPress Update API
*/
namespace App\Core;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
class DatabaseManager
{
private static ?self $instance = null;
private Connection $connection;
/**
* Initialize the database connection.
*/
private function __construct()
{
$params = [
'driver' => 'pdo_sqlite',
'path' => DB_FILE,
];
$this->connection = DriverManager::getConnection($params);
}
/**
* Get the Doctrine DBAL connection to the SQLite database.
* Lazily initializes the singleton on first call.
*/
public static function connection(): Connection
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance->connection;
}
}