File "CachingCollationMetadataProvider.php"

Full Path: /home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/vendor/doctrine/dbal/src/Platforms/MySQL/CollationMetadataProvider/CachingCollationMetadataProvider.php
File size: 787 bytes
MIME-type: text/x-php
Charset: utf-8

<?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);
    }
}