AbstractTranslation::getTranslatable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Locastic\ApiPlatformTranslationBundle\Model;
6
7
/**
8
 * Class AbstractTranslation
9
 *
10
 * @package Locastic\ApiPlatformTranslationBundle\Model
11
 */
12
abstract class AbstractTranslation implements TranslationInterface
13
{
14
    protected ?TranslatableInterface $translatable = null;
15
    protected ?string $locale = null;
16
    /**
17
     * @codeCoverageIgnore
18
     */
19
    public function getTranslatable(): ?TranslatableInterface
20
    {
21
        return $this->translatable;
22
    }
23
24
    public function setTranslatable(?TranslatableInterface $translatable): void
25
    {
26
        if ($translatable === $this->translatable) {
27
            return;
28
        }
29
30
        $previousTranslatable = $this->translatable;
31
        $this->translatable = $translatable;
32
33
        $previousTranslatable?->removeTranslation($this);
34
35
        $translatable?->addTranslation($this);
36
    }
37
38
    /**
39
     * @codeCoverageIgnore
40
     */
41
    public function getLocale(): ?string
42
    {
43
        return $this->locale;
44
    }
45
46
    /**
47
     * @codeCoverageIgnore
48
     */
49
    public function setLocale(?string $locale): void
50
    {
51
        $this->locale = $locale;
52
    }
53
}
54