<?php

declare(strict_types=1);

namespace PpPhp\Core\Database\Dialect;

final class UnsupportedDialect extends AbstractDatabaseDialect
{
    public function __construct(private readonly string $type) {}

    public function id(): string { return $this->type; }

    public function label(): string { return strtoupper($this->type); }

    protected function fieldTypes(): array { return ['VARCHAR']; }

    protected function typeSql(array $field): string { return 'VARCHAR(255)'; }

    protected function capabilities(): array
    {
        return array_map(static fn(): bool => false, parent::capabilities());
    }

    private function unsupported(): never
    {
        throw new \RuntimeException("The Tables designer does not yet have a {$this->label()} dialect adapter.");
    }

    public function listObjects(\PDO $pdo, array $config): array { $this->unsupported(); }
    public function describeTable(\PDO $pdo, string $table, array $config): array { $this->unsupported(); }
    public function createTable(\PDO $pdo, string $table, array $fields, array $config, array $foreignKeys = []): void { $this->unsupported(); }
    public function updateTable(\PDO $pdo, string $oldTable, string $newTable, array $fields, array $currentDetails, array $config): void { $this->unsupported(); }
    public function dropObject(\PDO $pdo, string $name, string $type, array $config): void { $this->unsupported(); }
    public function createView(\PDO $pdo, string $name, string $selectSql, bool $replace, array $config): void { $this->unsupported(); }
    public function preview(\PDO $pdo, string $selectSql, int $limit = 10): array { $this->unsupported(); }
    public function addForeignKey(\PDO $pdo, array $relation, array $config): void { $this->unsupported(); }
    public function dropForeignKey(\PDO $pdo, array $relation, array $config): void { $this->unsupported(); }
    public function countRows(\PDO $pdo, string $table, array $config): int { $this->unsupported(); }
}
