diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Portability/OptimizeFlags.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Portability/OptimizeFlags.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Portability/OptimizeFlags.php b/vendor/doctrine/dbal/src/Portability/OptimizeFlags.php new file mode 100644 index 0000000..c985d4b --- /dev/null +++ b/vendor/doctrine/dbal/src/Portability/OptimizeFlags.php | |||
@@ -0,0 +1,42 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Portability; | ||
6 | |||
7 | use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
8 | use Doctrine\DBAL\Platforms\DB2Platform; | ||
9 | use Doctrine\DBAL\Platforms\OraclePlatform; | ||
10 | use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
11 | use Doctrine\DBAL\Platforms\SQLitePlatform; | ||
12 | use Doctrine\DBAL\Platforms\SQLServerPlatform; | ||
13 | |||
14 | final class OptimizeFlags | ||
15 | { | ||
16 | /** | ||
17 | * Platform-specific portability flags that need to be excluded from the user-provided mode | ||
18 | * since the platform already operates in this mode to avoid unnecessary conversion overhead. | ||
19 | * | ||
20 | * @var array<class-string, int> | ||
21 | */ | ||
22 | private static array $platforms = [ | ||
23 | DB2Platform::class => 0, | ||
24 | OraclePlatform::class => Connection::PORTABILITY_EMPTY_TO_NULL, | ||
25 | PostgreSQLPlatform::class => 0, | ||
26 | SQLitePlatform::class => 0, | ||
27 | SQLServerPlatform::class => 0, | ||
28 | ]; | ||
29 | |||
30 | public function __invoke(AbstractPlatform $platform, int $flags): int | ||
31 | { | ||
32 | foreach (self::$platforms as $class => $mask) { | ||
33 | if ($platform instanceof $class) { | ||
34 | $flags &= ~$mask; | ||
35 | |||
36 | break; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | return $flags; | ||
41 | } | ||
42 | } | ||