Completed
Pull Request — master (#21)
by Valentyn
01:42
created

GenreTranslations   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 55
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A changeName() 0 4 1
A getName() 0 4 1
A getLocale() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Entity\Translations;
5
6
use App\Entity\Genre;
7
use App\Translation\EntityTranslationInterface;
8
use Doctrine\ORM\Mapping as ORM;
9
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
10
use JMS\Serializer\Annotation\Exclude;
11
use JMS\Serializer\Annotation\Expose;
12
13
/**
14
 * @ORM\Entity
15
 * @ORM\Table(name="genres_translations",
16
 *     uniqueConstraints={
17
 *      @ORM\UniqueConstraint(name="idx_GenreTranslations_locale_genre_id", columns={"locale", "genre_id"})
18
 *     })
19
 */
20
class GenreTranslations implements EntityTranslationInterface
21
{
22
    /**
23
     * @ORM\Id()
24
     * @ORM\GeneratedValue()
25
     * @ORM\Column(type="integer")
26
     * @Exclude
27
     */
28
    private $id;
29
30
    /**
31
     * @ORM\Column(type="string", length=5)
32
     */
33
    private $locale;
34
35
    /**
36
     * @Exclude
37
     * @ORM\ManyToOne(targetEntity="App\Entity\Genre", inversedBy="translations")
38
     * @ORM\JoinColumn(nullable=false)
39
     */
40
    private $genre;
41
42
    /**
43
     * @Expose
44
     * @ORM\Column(type="string", length=50)
45
     */
46
    private $name;
47
48 3
    public function __construct(Genre $genre, string $locale, string $name)
49
    {
50 3
        $this->genre = $genre;
51 3
        $this->locale = $locale;
52 3
        $this->name = $name;
53 3
    }
54
55
    public function getId()
56
    {
57
        return $this->id;
58
    }
59
60 1
    public function changeName(string $name)
61
    {
62 1
        $this->name = $name;
63 1
    }
64
65 1
    public function getName()
66
    {
67 1
        return $this->name;
68
    }
69
70 6
    public function getLocale():string
71
    {
72 6
        return $this->locale;
73
    }
74
}