Lines 85.71% 6 / 7
Methods 50.00% 1 / 2
Classes 0.00% 0 / 1
Covered by tests of size
Name Lines Methods CRAP
 create 0.00% 0 / 1 0.00% 0 / 1 2
 createForType 100.00% 6 / 6 100.00% 1 / 1 6
28class DialectFactory
29{
30    /**
31     * Creates the appropriate dialect for the current database type.
32     */
33    public static function create(): DialectInterface
34    {
35        return self::createForType(Database::getType());
36    }
37
38    /**
39     * Creates a dialect for the specified database type.
40     */
41    public static function createForType(string $dbType): DialectInterface
42    {
43        return match ($dbType) {
44            'mysqli', 'pdo_mysql' => new MysqlDialect(),
45            'pgsql', 'pdo_pgsql' => new PostgresDialect(),
46            'sqlite3', 'pdo_sqlite' => new SqliteDialect(),
47            'sqlsrv', 'pdo_sqlsrv' => new SqlServerDialect(),
48            default => throw new \InvalidArgumentException("Unsupported database type: {$dbType}"),
49        };
50    }
51}