Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/MessageFormatter/MessageFormatterMapper.php

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