Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 
12
namespace Carbon;
13
 
14
use Carbon\Exceptions\ImmutableException;
15
use Symfony\Component\Config\ConfigCacheFactoryInterface;
16
use Symfony\Component\Translation\Formatter\MessageFormatterInterface;
17
 
18
class TranslatorImmutable extends Translator
19
{
20
    /** @var bool */
21
    private $constructed = false;
22
 
23
    public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
24
    {
25
        parent::__construct($locale, $formatter, $cacheDir, $debug);
26
        $this->constructed = true;
27
    }
28
 
29
    /**
30
     * @codeCoverageIgnore
31
     */
32
    public function setDirectories(array $directories)
33
    {
34
        $this->disallowMutation(__METHOD__);
35
 
36
        return parent::setDirectories($directories);
37
    }
38
 
39
    public function setLocale($locale)
40
    {
41
        $this->disallowMutation(__METHOD__);
42
 
43
        return parent::setLocale($locale);
44
    }
45
 
46
    /**
47
     * @codeCoverageIgnore
48
     */
49
    public function setMessages($locale, $messages)
50
    {
51
        $this->disallowMutation(__METHOD__);
52
 
53
        return parent::setMessages($locale, $messages);
54
    }
55
 
56
    /**
57
     * @codeCoverageIgnore
58
     */
59
    public function setTranslations($messages)
60
    {
61
        $this->disallowMutation(__METHOD__);
62
 
63
        return parent::setTranslations($messages);
64
    }
65
 
66
    /**
67
     * @codeCoverageIgnore
68
     */
69
    public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory)
70
    {
71
        $this->disallowMutation(__METHOD__);
72
 
73
        parent::setConfigCacheFactory($configCacheFactory);
74
    }
75
 
76
    public function resetMessages($locale = null)
77
    {
78
        $this->disallowMutation(__METHOD__);
79
 
80
        return parent::resetMessages($locale);
81
    }
82
 
83
    /**
84
     * @codeCoverageIgnore
85
     */
86
    public function setFallbackLocales(array $locales)
87
    {
88
        $this->disallowMutation(__METHOD__);
89
 
90
        parent::setFallbackLocales($locales);
91
    }
92
 
93
    private function disallowMutation($method)
94
    {
95
        if ($this->constructed) {
96
            throw new ImmutableException($method.' not allowed on '.static::class);
97
        }
98
    }
99
}