Cli
2 years ago
Exceptions
1 month ago
Lang
2 years ago
Laravel
2 years ago
List
2 years ago
MessageFormatter
2 years ago
PHPStan
2 years ago
Traits
1 month ago
AbstractTranslator.php
1 month ago
Carbon.php
2 years ago
CarbonConverterInterface.php
2 years ago
CarbonImmutable.php
2 years ago
CarbonInterface.php
1 month ago
CarbonInterval.php
2 years ago
CarbonPeriod.php
1 month ago
CarbonPeriodImmutable.php
2 years ago
CarbonTimeZone.php
1 month ago
Factory.php
1 month ago
FactoryImmutable.php
2 years ago
Language.php
2 years ago
Translator.php
2 years ago
TranslatorImmutable.php
1 month ago
TranslatorStrongTypeInterface.php
2 years ago
TranslatorImmutable.php
83 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; |
| 12 | |
| 13 | use IAWPSCOPED\Carbon\Exceptions\ImmutableException; |
| 14 | use IAWPSCOPED\Symfony\Component\Config\ConfigCacheFactoryInterface; |
| 15 | use IAWPSCOPED\Symfony\Component\Translation\Formatter\MessageFormatterInterface; |
| 16 | /** @internal */ |
| 17 | class TranslatorImmutable extends Translator |
| 18 | { |
| 19 | /** @var bool */ |
| 20 | private $constructed = \false; |
| 21 | public function __construct($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = \false) |
| 22 | { |
| 23 | parent::__construct($locale, $formatter, $cacheDir, $debug); |
| 24 | $this->constructed = \true; |
| 25 | } |
| 26 | /** |
| 27 | * @codeCoverageIgnore |
| 28 | */ |
| 29 | public function setDirectories(array $directories) |
| 30 | { |
| 31 | $this->disallowMutation(__METHOD__); |
| 32 | return parent::setDirectories($directories); |
| 33 | } |
| 34 | public function setLocale($locale) |
| 35 | { |
| 36 | $this->disallowMutation(__METHOD__); |
| 37 | return parent::setLocale($locale); |
| 38 | } |
| 39 | /** |
| 40 | * @codeCoverageIgnore |
| 41 | */ |
| 42 | public function setMessages($locale, $messages) |
| 43 | { |
| 44 | $this->disallowMutation(__METHOD__); |
| 45 | return parent::setMessages($locale, $messages); |
| 46 | } |
| 47 | /** |
| 48 | * @codeCoverageIgnore |
| 49 | */ |
| 50 | public function setTranslations($messages) |
| 51 | { |
| 52 | $this->disallowMutation(__METHOD__); |
| 53 | return parent::setTranslations($messages); |
| 54 | } |
| 55 | /** |
| 56 | * @codeCoverageIgnore |
| 57 | */ |
| 58 | public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) : void |
| 59 | { |
| 60 | $this->disallowMutation(__METHOD__); |
| 61 | parent::setConfigCacheFactory($configCacheFactory); |
| 62 | } |
| 63 | public function resetMessages($locale = null) |
| 64 | { |
| 65 | $this->disallowMutation(__METHOD__); |
| 66 | return parent::resetMessages($locale); |
| 67 | } |
| 68 | /** |
| 69 | * @codeCoverageIgnore |
| 70 | */ |
| 71 | public function setFallbackLocales(array $locales) |
| 72 | { |
| 73 | $this->disallowMutation(__METHOD__); |
| 74 | parent::setFallbackLocales($locales); |
| 75 | } |
| 76 | private function disallowMutation($method) |
| 77 | { |
| 78 | if ($this->constructed) { |
| 79 | throw new ImmutableException($method . ' not allowed on ' . static::class); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 |