mailpoet
/
vendor-prefixed
/
doctrine
/
dbal
/
src
/
Platforms
/
MySQL
/
CollationMetadataProvider
/
CachingCollationMetadataProvider.php
mailpoet
/
vendor-prefixed
/
doctrine
/
dbal
/
src
/
Platforms
/
MySQL
/
CollationMetadataProvider
Last commit date
CachingCollationMetadataProvider.php
2 years ago
ConnectionCollationMetadataProvider.php
2 years ago
index.php
2 years ago
CachingCollationMetadataProvider.php
23 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Platforms\MySQL\CollationMetadataProvider; |
| 6 | use function array_key_exists; |
| 7 | final class CachingCollationMetadataProvider implements CollationMetadataProvider |
| 8 | { |
| 9 | private $collationMetadataProvider; |
| 10 | private $cache = []; |
| 11 | public function __construct(CollationMetadataProvider $collationMetadataProvider) |
| 12 | { |
| 13 | $this->collationMetadataProvider = $collationMetadataProvider; |
| 14 | } |
| 15 | public function getCollationCharset(string $collation) : ?string |
| 16 | { |
| 17 | if (array_key_exists($collation, $this->cache)) { |
| 18 | return $this->cache[$collation]; |
| 19 | } |
| 20 | return $this->cache[$collation] = $this->collationMetadataProvider->getCollationCharset($collation); |
| 21 | } |
| 22 | } |
| 23 |