| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 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 |
|
| 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 |
|
| 27 |
|
| 28 |
final class MessageFormatterMapper extends LazyMessageFormatter |
| 29 |
{ |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 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 |
} |