Passed
Push — develop ( df9e56...fcc4e3 )
by BENARD
12:25
created

Country   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 216
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 18
eloc 35
c 1
b 0
f 0
dl 0
loc 216
rs 10

18 Methods

Rating   Name   Duplication   Size   Complexity  
A setCodeIso2() 0 5 1
A setBadge() 0 5 1
A getCodeIsoNumeric() 0 3 1
A getBadge() 0 3 1
A getBoolMaj() 0 3 1
A setCodeIsoNumeric() 0 4 1
A setName() 0 5 1
A getSlug() 0 3 1
A getId() 0 3 1
A setCodeIso3() 0 4 1
A getCodeIso3() 0 3 1
A getDefaultName() 0 3 1
A setSlug() 0 3 1
A __toString() 0 3 1
A setId() 0 5 1
A setBoolMaj() 0 5 1
A getCodeIso2() 0 3 1
A getName() 0 3 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Entity;
4
5
use ApiPlatform\Core\Annotation\ApiResource;
6
use Doctrine\ORM\Mapping as ORM;
7
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
8
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait;
9
use Knp\DoctrineBehaviors\Model\Translatable\TranslatablePropertiesTrait;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
/**
13
 * Country
14
 *
15
 * @ORM\Table(name="vgr_country")
16
 * @ORM\Entity
17
 * @ApiResource(attributes={"order"={"translations.name"}})
18
 */
19
class Country implements TranslatableInterface
20
{
21
    use TranslatablePropertiesTrait;
22
    use TranslatableMethodsTrait;
23
24
    /**
25
     * @Assert\Length(min="2", max="2")
26
     * @ORM\Column(name="code_iso2", type="string", length=2, nullable=false)
27
     */
28
    private string $codeIso2;
29
30
    /**
31
     * @Assert\Length(min="3", max="3")
32
     * @ORM\Column(name="code_iso3", type="string", length=3, nullable=false)
33
     */
34
    private string $codeIso3;
35
36
    /**
37
     * @ORM\Column(name="code_iso_numeric", type="integer", nullable=false)
38
     */
39
    private int $codeIsoNumeric;
40
41
    /**
42
     * @ORM\Column(name="slug", type="string", length=100, nullable=true)
43
     */
44
    private string $slug;
45
46
    /**
47
     * @ORM\Column(name="id", type="integer")
48
     * @ORM\Id
49
     * @ORM\GeneratedValue(strategy="IDENTITY")
50
     */
51
    private ?int $id = null;
52
53
    /**
54
     * @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Badge", inversedBy="country")
55
     * @ORM\JoinColumns({
56
     *   @ORM\JoinColumn(name="idBadge", referencedColumnName="id")
57
     * })
58
     */
59
    private ?Badge $badge;
60
61
    /**
62
     * @ORM\Column(name="boolMaj", type="boolean", nullable=false, options={"default":0})
63
     */
64
    private bool $boolMaj = false;
65
66
    /**
67
     * Set codeIso
68
     *
69
     * @param string $codeIso2
70
     * @return Country
71
     */
72
    public function setCodeIso2(string $codeIso2): Country
73
    {
74
        $this->codeIso2 = $codeIso2;
75
76
        return $this;
77
    }
78
79
    /**
80
     * Get codeIso
81
     *
82
     * @return string
83
     */
84
    public function getCodeIso2(): string
85
    {
86
        return $this->codeIso2;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getCodeIso3(): string
93
    {
94
        return $this->codeIso3;
95
    }
96
97
    /**
98
     * @param string $codeIso3
99
     * @return Country
100
     */
101
    public function setCodeIso3(string $codeIso3): Country
102
    {
103
        $this->codeIso3 = $codeIso3;
104
        return $this;
105
    }
106
107
    /**
108
     * @return int
109
     */
110
    public function getCodeIsoNumeric(): int
111
    {
112
        return $this->codeIsoNumeric;
113
    }
114
115
    /**
116
     * @param int $codeIsoNumeric
117
     * @return Country
118
     */
119
    public function setCodeIsoNumeric(int $codeIsoNumeric): Country
120
    {
121
        $this->codeIsoNumeric = $codeIsoNumeric;
122
        return $this;
123
    }
124
125
    /**
126
     * @param string $name
127
     * @return $this
128
     */
129
    public function setName(string $name): Country
130
    {
131
        $this->translate(null, false)->setName($name);
0 ignored issues
show
Bug introduced by
The method setName() does not exist on Knp\DoctrineBehaviors\Co...ty\TranslationInterface. It seems like you code against a sub-type of said class. However, the method does not exist in VideoGamesRecords\CoreBu...\Entity\RuleTranslation or VideoGamesRecords\CoreBu...Entity\SerieTranslation. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

131
        $this->translate(null, false)->/** @scrutinizer ignore-call */ setName($name);
Loading history...
132
133
        return $this;
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    public function getName(): string
140
    {
141
        return $this->translate(null, false)->getName();
0 ignored issues
show
Bug introduced by
The method getName() does not exist on Knp\DoctrineBehaviors\Co...ty\TranslationInterface. It seems like you code against a sub-type of said class. However, the method does not exist in VideoGamesRecords\CoreBu...\Entity\RuleTranslation or VideoGamesRecords\CoreBu...Entity\SerieTranslation. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
        return $this->translate(null, false)->/** @scrutinizer ignore-call */ getName();
Loading history...
142
    }
143
144
    /**
145
     * Get id
146
     *
147
     * @return int|null
148
     */
149
    public function getId(): ?int
150
    {
151
        return $this->id;
152
    }
153
154
    /**
155
     * Set id
156
     *
157
     * @param int $id
158
     * @return $this
159
     */
160
    public function setId(int $id): Country
161
    {
162
        $this->id = $id;
163
164
        return $this;
165
    }
166
167
    /**
168
     * set badge
169
     * @param Badge|null $badge
170
     * @return $this
171
     */
172
    public function setBadge(Badge $badge = null): Country
173
    {
174
        $this->badge = $badge;
175
176
        return $this;
177
    }
178
179
    /**
180
     * Get idBadge
181
     * @return Badge|null
182
     */
183
    public function getBadge(): ?Badge
184
    {
185
        return $this->badge;
186
    }
187
188
    /**
189
     * Set boolMaj
190
     *
191
     * @param boolean $boolMaj
192
     * @return $this
193
     */
194
    public function setBoolMaj(bool $boolMaj): Country
195
    {
196
        $this->boolMaj = $boolMaj;
197
198
        return $this;
199
    }
200
201
    /**
202
     * Get boolMaj
203
     *
204
     * @return bool
205
     */
206
    public function getBoolMaj(): bool
207
    {
208
        return $this->boolMaj;
209
    }
210
211
    public function getSlug(): string
212
    {
213
        return $this->slug;
214
    }
215
216
    public function setSlug(string $slug): void
217
    {
218
        $this->slug = $slug;
219
    }
220
221
    /**
222
     * @return string
223
     */
224
    public function __toString()
225
    {
226
        return sprintf('%s [%d]', $this->getDefaultName(), $this->getId());
227
    }
228
229
    /**
230
     * @return string
231
     */
232
    public function getDefaultName(): string
233
    {
234
        return $this->translate('en', false)->getName();
235
    }
236
}
237