independent-analytics
/
vendor
/
nesbot
/
carbon
/
src
/
Carbon
/
MessageFormatter
/
MessageFormatterMapper.php
MessageFormatterMapper.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of the Carbon package. |
| 5 | * |
| 6 | * (c) Brian Nesbitt <brian@nesbot.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace IAWPSCOPED\Carbon\MessageFormatter; |
| 12 | |
| 13 | use ReflectionMethod; |
| 14 | use IAWPSCOPED\Symfony\Component\Translation\Formatter\MessageFormatter; |
| 15 | use IAWPSCOPED\Symfony\Component\Translation\Formatter\MessageFormatterInterface; |
| 16 | // @codeCoverageIgnoreStart |
| 17 | $transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format'); |
| 18 | require $transMethod->getParameters()[0]->hasType() ? __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php' : __DIR__ . '/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php'; |
| 19 | // @codeCoverageIgnoreEnd |
| 20 | /** @internal */ |
| 21 | final class MessageFormatterMapper extends LazyMessageFormatter |
| 22 | { |
| 23 | /** |
| 24 | * Wrapped formatter. |
| 25 | * |
| 26 | * @var MessageFormatterInterface |
| 27 | */ |
| 28 | protected $formatter; |
| 29 | public function __construct(?MessageFormatterInterface $formatter = null) |
| 30 | { |
| 31 | $this->formatter = $formatter ?? new MessageFormatter(); |
| 32 | } |
| 33 | protected function transformLocale(?string $locale) : ?string |
| 34 | { |
| 35 | return $locale ? \preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale; |
| 36 | } |
| 37 | } |
| 38 |