Spaces:
No application file
No application file
declare(strict_types=1); | |
namespace Mautic\CoreBundle\Doctrine; | |
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; | |
use Doctrine\DBAL\Platforms\AbstractPlatform; | |
use Doctrine\DBAL\Platforms\DB2Platform; | |
use Doctrine\DBAL\Platforms\OraclePlatform; | |
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | |
use Doctrine\DBAL\Platforms\SqlitePlatform; | |
use Doctrine\DBAL\Platforms\SQLServerPlatform; | |
/** | |
* A workaround for deprecated \Doctrine\DBAL\Platforms\AbstractPlatform::getName. | |
*/ | |
class DatabasePlatform | |
{ | |
public static function getDatabasePlatform(AbstractPlatform $platform): string | |
{ | |
if ($platform instanceof AbstractMySQLPlatform) { | |
return 'mysql'; | |
} | |
if ($platform instanceof DB2Platform) { | |
return 'db2'; | |
} | |
if ($platform instanceof OraclePlatform) { | |
return 'oracle'; | |
} | |
if ($platform instanceof PostgreSQLPlatform) { | |
return 'postgresql'; | |
} | |
if ($platform instanceof SQLServerPlatform) { | |
return 'mssql'; | |
} | |
if ($platform instanceof SqlitePlatform) { | |
return 'sqlite'; | |
} | |
throw new \RuntimeException('Unknown platform '.$platform::class); | |
} | |
} | |