Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
17 | class Folder |
||
18 | { |
||
19 | /** |
||
20 | * @ORM\Id |
||
21 | * @ORM\Column(type="bigint") |
||
22 | * @ORM\GeneratedValue(strategy="AUTO") |
||
23 | */ |
||
24 | protected $id; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | * |
||
29 | * @Gedmo\Translatable |
||
30 | * @ORM\Column(type="string") |
||
31 | * @Assert\NotBlank() |
||
32 | */ |
||
33 | protected $name; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | * |
||
38 | * @Gedmo\Locale |
||
39 | * Used locale to override Translation listener`s locale |
||
40 | * this is not a mapped field of entity metadata, just a simple property |
||
41 | */ |
||
42 | protected $locale; |
||
43 | |||
44 | /** |
||
45 | * @var Folder |
||
46 | * |
||
47 | * @ORM\ManyToOne(targetEntity="Folder", inversedBy="children", fetch="EAGER", cascade={"persist", "remove"}) |
||
48 | * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true, onDelete="SET NULL") |
||
49 | */ |
||
50 | protected $parent; |
||
51 | |||
52 | /** |
||
53 | * @var ArrayCollection |
||
54 | * |
||
55 | * @ORM\OneToMany(targetEntity="Folder", mappedBy="parent", fetch="LAZY") |
||
56 | * @ORM\OrderBy({"name" = "ASC"}) |
||
57 | */ |
||
58 | protected $children; |
||
59 | |||
60 | /** |
||
61 | * @var ArrayCollection |
||
62 | * |
||
63 | * @ORM\OneToMany(targetEntity="Media", mappedBy="folder") |
||
64 | */ |
||
65 | protected $media; |
||
66 | |||
67 | /** |
||
68 | * @var \DateTime |
||
69 | * |
||
70 | * @ORM\Column(type="datetime", name="created_at") |
||
71 | */ |
||
72 | protected $createdAt; |
||
73 | |||
74 | /** |
||
75 | * @var \DateTime |
||
76 | * |
||
77 | * @ORM\Column(type="datetime", name="updated_at") |
||
78 | */ |
||
79 | protected $updatedAt; |
||
80 | |||
81 | /** |
||
82 | * @var string |
||
83 | * |
||
84 | * @ORM\Column(type="string", nullable=true) |
||
85 | */ |
||
86 | protected $rel; |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | * |
||
91 | * @ORM\Column(type="string", name="internal_name", nullable=true) |
||
92 | */ |
||
93 | protected $internalName; |
||
94 | |||
95 | /** |
||
96 | * @var bool |
||
97 | * |
||
98 | * @ORM\Column(type="boolean") |
||
99 | */ |
||
100 | protected $deleted; |
||
101 | |||
102 | /** |
||
103 | * constructor. |
||
104 | */ |
||
105 | public function __construct() |
||
113 | |||
114 | /** |
||
115 | * Get id. |
||
116 | * |
||
117 | * @return int |
||
118 | */ |
||
119 | public function getId() |
||
123 | |||
124 | /** |
||
125 | * Set id. |
||
126 | * |
||
127 | * @param int $id The unique identifier |
||
128 | */ |
||
129 | public function setId($id) |
||
133 | |||
134 | /** |
||
135 | * @param string $name |
||
136 | * |
||
137 | * @return Folder |
||
138 | */ |
||
139 | public function setName($name) |
||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getName() |
||
153 | |||
154 | /** |
||
155 | * @param string $locale |
||
156 | * |
||
157 | * @return Folder |
||
158 | */ |
||
159 | public function setTranslatableLocale($locale) |
||
165 | |||
166 | /** |
||
167 | * @param string $rel |
||
168 | * |
||
169 | * @return Folder |
||
170 | */ |
||
171 | public function setRel($rel) |
||
177 | |||
178 | /** |
||
179 | * @return string |
||
180 | */ |
||
181 | public function getRel() |
||
185 | |||
186 | /** |
||
187 | * Set createdAd. |
||
188 | * |
||
189 | * @param \DateTime $createdAt |
||
190 | * |
||
191 | * @return Folder |
||
192 | */ |
||
193 | public function setCreatedAt($createdAt) |
||
199 | |||
200 | /** |
||
201 | * Get createdAd. |
||
202 | * |
||
203 | * @return \DateTime |
||
204 | */ |
||
205 | public function getCreatedAt() |
||
209 | |||
210 | /** |
||
211 | * Set updatedAt. |
||
212 | * |
||
213 | * @param \DateTime $updatedAt |
||
214 | * |
||
215 | * @return Folder |
||
216 | */ |
||
217 | public function setUpdatedAt($updatedAt) |
||
223 | |||
224 | /** |
||
225 | * Get updatedAt. |
||
226 | * |
||
227 | * @return \DateTime |
||
228 | */ |
||
229 | public function getUpdatedAt() |
||
233 | |||
234 | /** |
||
235 | * Set parent. |
||
236 | * |
||
237 | * @param Folder $parent |
||
238 | * |
||
239 | * @return Folder |
||
240 | */ |
||
241 | public function setParent(Folder $parent) |
||
247 | |||
248 | /** |
||
249 | * Get parent. |
||
250 | * |
||
251 | * @return Folder |
||
252 | */ |
||
253 | public function getParent() |
||
257 | |||
258 | /** |
||
259 | * @return Folder[]: |
||
|
|||
260 | */ |
||
261 | public function getParents() |
||
272 | |||
273 | /** |
||
274 | * Add a child. |
||
275 | * |
||
276 | * @param Folder $child |
||
277 | * |
||
278 | * @return Folder |
||
279 | */ |
||
280 | public function addChild(Folder $child) |
||
287 | |||
288 | /** |
||
289 | * @param bool $includeDeleted |
||
290 | * |
||
291 | * @return ArrayCollection |
||
292 | */ |
||
293 | View Code Duplication | public function getChildren($includeDeleted = false) |
|
307 | |||
308 | /** |
||
309 | * @param array $children |
||
310 | * |
||
311 | * @return Folder |
||
312 | */ |
||
313 | public function setChildren($children) |
||
319 | |||
320 | /** |
||
321 | * @return bool |
||
322 | */ |
||
323 | public function isDeleted() |
||
327 | |||
328 | /** |
||
329 | * @param bool $deleted |
||
330 | * |
||
331 | * @return Folder |
||
332 | */ |
||
333 | public function setDeleted($deleted) |
||
339 | |||
340 | /** |
||
341 | * Add file. |
||
342 | * |
||
343 | * @param Media $media |
||
344 | * |
||
345 | * @return Folder |
||
346 | */ |
||
347 | public function addMedia(Media $media) |
||
353 | |||
354 | /** |
||
355 | * Get media. |
||
356 | * |
||
357 | * @param bool $includeDeleted |
||
358 | * |
||
359 | * @return ArrayCollection |
||
360 | */ |
||
361 | View Code Duplication | public function getMedia($includeDeleted = false) |
|
375 | |||
376 | /** |
||
377 | * @param int $id |
||
378 | * |
||
379 | * @return bool |
||
380 | */ |
||
381 | public function hasActive($id) |
||
391 | |||
392 | /** |
||
393 | * @param string $internalName |
||
394 | * |
||
395 | * @return Folder |
||
396 | */ |
||
397 | public function setInternalName($internalName) |
||
403 | |||
404 | /** |
||
405 | * @return string |
||
406 | */ |
||
407 | public function getInternalName() |
||
411 | |||
412 | /** |
||
413 | * @return string |
||
414 | */ |
||
415 | public function __toString() |
||
419 | |||
420 | /** |
||
421 | * @ORM\PreUpdate |
||
422 | */ |
||
423 | public function preUpdate() |
||
427 | } |
||
428 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.