mailpoet
/
vendor-prefixed
/
nesbot
/
carbon
/
src
/
Carbon
/
MessageFormatter
/
MessageFormatterMapper.php
MessageFormatterMapper.php
23 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Carbon\MessageFormatter; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use ReflectionMethod; |
| 5 | use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatter; |
| 6 | use MailPoetVendor\Symfony\Component\Translation\Formatter\MessageFormatterInterface; |
| 7 | // @codeCoverageIgnoreStart |
| 8 | $transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format'); |
| 9 | require $transMethod->getParameters()[0]->hasType() ? __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php' : __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php'; |
| 10 | // @codeCoverageIgnoreEnd |
| 11 | final class MessageFormatterMapper extends LazyMessageFormatter |
| 12 | { |
| 13 | protected $formatter; |
| 14 | public function __construct(?MessageFormatterInterface $formatter = null) |
| 15 | { |
| 16 | $this->formatter = $formatter ?? new MessageFormatter(); |
| 17 | } |
| 18 | protected function transformLocale(?string $locale) : ?string |
| 19 | { |
| 20 | return $locale ? \preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale; |
| 21 | } |
| 22 | } |
| 23 |