Total Complexity | 6 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | abstract class AbstractTranslation implements TranslationInterface |
||
13 | { |
||
14 | protected ?TranslatableInterface $translatable = null; |
||
15 | |||
16 | public function __construct( |
||
17 | protected ?string $locale = null, |
||
18 | ?TranslatableInterface $translatable = null |
||
19 | ) { |
||
20 | $this->setTranslatable($translatable); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @codeCoverageIgnore |
||
25 | */ |
||
26 | public function getTranslatable(): ?TranslatableInterface |
||
27 | { |
||
28 | return $this->translatable; |
||
29 | } |
||
30 | |||
31 | public function setTranslatable(?TranslatableInterface $translatable): void |
||
32 | { |
||
33 | if ($translatable === $this->translatable) { |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | $previousTranslatable = $this->translatable; |
||
38 | $this->translatable = $translatable; |
||
39 | |||
40 | $previousTranslatable?->removeTranslation($this); |
||
41 | |||
42 | $translatable?->addTranslation($this); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @codeCoverageIgnore |
||
47 | */ |
||
48 | public function getLocale(): ?string |
||
49 | { |
||
50 | return $this->locale; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @codeCoverageIgnore |
||
55 | */ |
||
56 | public function setLocale(?string $locale): void |
||
59 | } |
||
60 | } |
||
61 |