summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Portability/OptimizeFlags.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Portability/OptimizeFlags.php')
-rw-r--r--vendor/doctrine/dbal/src/Portability/OptimizeFlags.php42
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
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Portability;
6
7use Doctrine\DBAL\Platforms\AbstractPlatform;
8use Doctrine\DBAL\Platforms\DB2Platform;
9use Doctrine\DBAL\Platforms\OraclePlatform;
10use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
11use Doctrine\DBAL\Platforms\SQLitePlatform;
12use Doctrine\DBAL\Platforms\SQLServerPlatform;
13
14final 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}