blob: 0c99aa3136625082adf78f95c89a9ef934ea084e (
plain)
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
|
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider;
use Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider;
use function array_key_exists;
/** @internal */
final class CachingCollationMetadataProvider implements CollationMetadataProvider
{
/** @var array<string,?string> */
private array $cache = [];
public function __construct(private readonly CollationMetadataProvider $collationMetadataProvider)
{
}
public function getCollationCharset(string $collation): ?string
{
if (array_key_exists($collation, $this->cache)) {
return $this->cache[$collation];
}
return $this->cache[$collation] = $this->collationMetadataProvider->getCollationCharset($collation);
}
}
|