These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\TranslatorBundle\Entity; |
||
4 | |||
5 | use DateTime; |
||
6 | use Doctrine\ORM\Mapping as ORM; |
||
7 | use Kunstmaan\TranslatorBundle\Model\Translation as TranslationModel; |
||
8 | use Symfony\Component\Validator\Constraints as Assert; |
||
9 | |||
10 | /** |
||
11 | * @ORM\Entity(repositoryClass="Kunstmaan\TranslatorBundle\Repository\TranslationRepository") |
||
12 | * @ORM\Table( |
||
13 | * name="kuma_translation", |
||
14 | * uniqueConstraints={ |
||
15 | * @ORM\UniqueConstraint(name="keyword_per_locale", columns={"keyword", "locale", "domain"}), |
||
16 | * @ORM\UniqueConstraint(name="translation_id_per_locale", columns={"translation_id", "locale"}), |
||
17 | * }, |
||
18 | * indexes={@ORM\Index(name="idx_translation_locale_domain", columns={"locale", "domain"})} |
||
19 | * ) |
||
20 | * @ORM\HasLifecycleCallbacks |
||
21 | */ |
||
22 | class Translation |
||
23 | { |
||
24 | const FLAG_NEW = 'new'; |
||
25 | const FLAG_UPDATED = 'updated'; |
||
26 | const STATUS_DEPRECATED = 'deprecated'; |
||
27 | const STATUS_DISABLED = 'disabled'; |
||
28 | const STATUS_ENABLED = 'enabled'; |
||
29 | |||
30 | /** |
||
31 | * @ORM\Id |
||
32 | * @ORM\Column(type="integer") |
||
33 | * @ORM\GeneratedValue(strategy="AUTO") |
||
34 | */ |
||
35 | protected $id; |
||
36 | |||
37 | /** |
||
38 | * @ORM\Column(type="integer", name="translation_id", nullable=true) |
||
39 | * @Assert\NotBlank() |
||
40 | */ |
||
41 | protected $translationId; |
||
42 | |||
43 | /** |
||
44 | * The translations keyword to use in your template or call from the translator |
||
45 | * |
||
46 | * @ORM\Column(type="string", nullable=true) |
||
47 | * @Assert\NotBlank() |
||
48 | */ |
||
49 | protected $keyword; |
||
50 | |||
51 | /** |
||
52 | * The translations keyword to use in your template or call from the translator |
||
53 | * |
||
54 | * @ORM\Column(type="string", length=5, nullable=true) |
||
55 | * @Assert\NotBlank() |
||
56 | */ |
||
57 | protected $locale; |
||
58 | |||
59 | /** |
||
60 | * @var string $status |
||
61 | * The translations deprecation date |
||
62 | * |
||
63 | * @ORM\column(type="string", length=10, options={"default" : "enabled"}) |
||
64 | */ |
||
65 | protected $status = self::STATUS_ENABLED; |
||
66 | |||
67 | /** |
||
68 | * Location where the translation comes from |
||
69 | * |
||
70 | * @ORM\Column(type="string", length=50, nullable=true) |
||
71 | */ |
||
72 | protected $file; |
||
73 | |||
74 | /** |
||
75 | * Translation |
||
76 | * |
||
77 | * @var string |
||
78 | * @ORM\Column(type="text", nullable=true) |
||
79 | * @Assert\NotBlank() |
||
80 | */ |
||
81 | protected $text; |
||
82 | |||
83 | /** |
||
84 | * @ORM\Column(type="string", length=30, nullable=true) |
||
85 | * @Assert\NotBlank() |
||
86 | */ |
||
87 | protected $domain; |
||
88 | |||
89 | /** |
||
90 | * @var \DateTime |
||
91 | * |
||
92 | * @ORM\Column(type="datetime", name="created_at", nullable=true) |
||
93 | */ |
||
94 | protected $createdAt; |
||
95 | |||
96 | /** |
||
97 | * @var \DateTime |
||
98 | * |
||
99 | * @ORM\Column(type="datetime", name="updated_at", nullable=true) |
||
100 | */ |
||
101 | protected $updatedAt; |
||
102 | |||
103 | /** |
||
104 | * A flag which defines the status of a specific translations ('updated', 'new', ..) |
||
105 | * |
||
106 | * @var string |
||
107 | * |
||
108 | * @ORM\Column(type="string", length=20, nullable=true) |
||
109 | */ |
||
110 | protected $flag = null; |
||
111 | |||
112 | /** |
||
113 | * @ORM\PrePersist |
||
114 | */ |
||
115 | View Code Duplication | public function prePersist() |
|
116 | { |
||
117 | $this->createdAt = new DateTime(); |
||
118 | $this->updatedAt = new DateTime(); |
||
119 | $this->flag = self::FLAG_NEW; |
||
120 | |||
121 | return $this->id; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @ORM\PreUpdate |
||
126 | */ |
||
127 | View Code Duplication | public function preUpdate() |
|
128 | { |
||
129 | $this->updatedAt = new DateTime(); |
||
130 | |||
131 | if ($this->flag === null) { |
||
132 | $this->flag = self::FLAG_UPDATED; |
||
133 | } |
||
134 | |||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getId() |
||
141 | { |
||
142 | return $this->id; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * @param string $id |
||
147 | * @return Translation |
||
148 | */ |
||
149 | public function setId($id) |
||
150 | { |
||
151 | $this->id = $id; |
||
152 | |||
153 | return $this; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getKeyword() |
||
160 | { |
||
161 | return $this->keyword; |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @param string $keyword |
||
166 | * @return Translation |
||
167 | */ |
||
168 | public function setKeyword($keyword) |
||
169 | { |
||
170 | $this->keyword = $keyword; |
||
171 | |||
172 | return $this; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * @return string |
||
177 | */ |
||
178 | public function getLocale() |
||
179 | { |
||
180 | return $this->locale; |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @param string $locale |
||
185 | * @return Translation |
||
186 | */ |
||
187 | public function setLocale($locale) |
||
188 | { |
||
189 | $this->locale = $locale; |
||
190 | |||
191 | return $this; |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * @return string |
||
196 | */ |
||
197 | public function getFile() |
||
198 | { |
||
199 | return $this->file; |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * @param string $file |
||
204 | * @return Translation |
||
205 | */ |
||
206 | public function setFile($file) |
||
207 | { |
||
208 | $this->file = $file; |
||
209 | |||
210 | return $this; |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * @return string |
||
215 | */ |
||
216 | public function getText() |
||
217 | { |
||
218 | return $this->text; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @param string $text |
||
223 | * @return Translation |
||
224 | */ |
||
225 | public function setText($text) |
||
226 | { |
||
227 | $this->text = $text; |
||
228 | |||
229 | return $this; |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * @return string |
||
234 | */ |
||
235 | public function getDomain() |
||
236 | { |
||
237 | return $this->domain; |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * @param string $domain |
||
242 | * @return Translation |
||
243 | */ |
||
244 | public function setDomain($domain) |
||
245 | { |
||
246 | $this->domain = $domain; |
||
247 | |||
248 | return $this; |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * @return \DateTime |
||
253 | */ |
||
254 | public function getCreatedAt() |
||
255 | { |
||
256 | return $this->createdAt; |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @param \DateTime $createdAt |
||
261 | * @return Translation |
||
262 | */ |
||
263 | public function setCreatedAt(DateTime $createdAt) |
||
264 | { |
||
265 | $this->createdAt = $createdAt; |
||
266 | |||
267 | return $this; |
||
268 | } |
||
269 | |||
270 | /** |
||
271 | * @return \DateTime |
||
272 | */ |
||
273 | public function getUpdatedAt() |
||
274 | { |
||
275 | return $this->updatedAt; |
||
276 | } |
||
277 | |||
278 | /** |
||
279 | * @param DateTime $updatedAt |
||
280 | * @return Translation |
||
281 | */ |
||
282 | public function setUpdatedAt(DateTime $updatedAt) |
||
283 | { |
||
284 | $this->updatedAt = $updatedAt; |
||
285 | |||
286 | return $this; |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * @return string |
||
291 | */ |
||
292 | public function getFlag() |
||
293 | { |
||
294 | return $this->flag; |
||
295 | } |
||
296 | |||
297 | /** |
||
298 | * @param string $flag |
||
299 | * @return Translation |
||
300 | */ |
||
301 | public function setFlag($flag) |
||
302 | { |
||
303 | $this->flag = $flag; |
||
304 | |||
305 | return $this; |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * @param string $translationId |
||
310 | * @return Translation |
||
311 | */ |
||
312 | public function setTranslationId($translationId) |
||
313 | { |
||
314 | $this->translationId = $translationId; |
||
315 | |||
316 | return $this; |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * @return string |
||
321 | */ |
||
322 | public function getTranslationId() |
||
323 | { |
||
324 | return $this->translationId; |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * @return string |
||
329 | */ |
||
330 | public function getStatus() |
||
331 | { |
||
332 | return $this->status; |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * @param string $status |
||
337 | * @return Translation |
||
338 | */ |
||
339 | public function setStatus($status) |
||
340 | { |
||
341 | $this->status = $status; |
||
342 | return $this; |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @return boolean |
||
347 | */ |
||
348 | public function isDisabled() |
||
349 | { |
||
350 | return $this->getStatus() === self::STATUS_DISABLED; |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @return boolean |
||
355 | */ |
||
356 | public function isDeprecated() |
||
357 | { |
||
358 | return $this->getStatus() === self::STATUS_DEPRECATED; |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * @param integer $id |
||
0 ignored issues
–
show
|
|||
363 | * |
||
364 | * @return TranslationModel |
||
365 | */ |
||
366 | public function getTranslationModel($id = null) |
||
367 | { |
||
368 | $translationModel = new TranslationModel(); |
||
369 | $translationModel->setKeyword($this->getKeyword()); |
||
370 | $translationModel->setDomain($this->getDomain()); |
||
371 | $translationModel->addText($this->getLocale(), $this->getText(), $id); |
||
372 | return $translationModel; |
||
373 | } |
||
374 | } |
||
375 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.