Spaces:
No application file
No application file
File size: 1,238 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
<?php
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);
}
}
|