AbstractTranslation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 12
c 1
b 0
f 0
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setLocale() 0 3 1
A getLocale() 0 3 1
A setTranslatable() 0 12 2
A getTranslatable() 0 3 1
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