<?php

namespace Slovocast\Infrastructure;

use League\Config\Configuration;
use Nette\Schema\Expect;
use PDO;

/**
 * Represents an active connection to a database
 */
class DatabaseConnection
{
    private PDO $pdo;

    public function __construct(Configuration $config)
    {
        $this->pdo = new PDO();
    }

    public function getConnection(): PDO
    {
        return $this->pdo;
    }

    public static function getConfigSchema(): Configuration
    {
        return new Configuration([
            'database' => Expect::structure([
                'driver' => Expect::anyOf('mysql', 'sqlite')->required(),
                'host' => Expect::string()->default('localhost'),
                'post' => Expect::int()->min(1)->max(65535),
                'database' => Expect::string()->required(),
                'username' => Expect::string()->required(),
                'password' => Expect::string()->nullable()
            ])
        ]);
    }
}
