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:
Complex classes like Item often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Item, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
41 | class Item extends BaseEntity implements ImageInterface |
||
42 | { |
||
43 | /** |
||
44 | * Id |
||
45 | * |
||
46 | * @ORM\Id |
||
47 | * @ORM\GeneratedValue |
||
48 | * @ORM\Column(type="integer") |
||
49 | * |
||
50 | * @var integer |
||
51 | */ |
||
52 | protected $id = 0; |
||
53 | |||
54 | /** |
||
55 | * Main name |
||
56 | * |
||
57 | * @ORM\Column(type="string", length=256) |
||
58 | * @Assert\NotBlank() |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $name = ''; |
||
63 | |||
64 | /** |
||
65 | * Main name |
||
66 | * |
||
67 | * @ORM\OneToMany(targetEntity="Name", mappedBy="item", cascade={"persist", "remove"}, orphanRemoval=true) |
||
68 | * |
||
69 | * @var \Doctrine\Common\Collections\ArrayCollection |
||
70 | */ |
||
71 | protected $names; |
||
72 | |||
73 | /** |
||
74 | * Type |
||
75 | * |
||
76 | * @ORM\ManyToOne(targetEntity="Type", inversedBy="items", cascade={"persist"}) |
||
77 | * @ORM\JoinColumn(name="type", referencedColumnName="id") |
||
78 | * |
||
79 | * @var \AnimeDb\Bundle\CatalogBundle\Entity\Type |
||
80 | */ |
||
81 | protected $type; |
||
82 | |||
83 | /** |
||
84 | * Date premiere |
||
85 | * |
||
86 | * @ORM\Column(type="date") |
||
87 | * @Assert\Date() |
||
88 | * |
||
89 | * @var \DateTime |
||
90 | */ |
||
91 | protected $date_premiere; |
||
92 | |||
93 | /** |
||
94 | * Date end release |
||
95 | * |
||
96 | * @ORM\Column(type="date", nullable=true) |
||
97 | * @Assert\Date() |
||
98 | * |
||
99 | * @var \DateTime|null |
||
100 | */ |
||
101 | protected $date_end; |
||
102 | |||
103 | /** |
||
104 | * Genre list |
||
105 | * |
||
106 | * @ORM\ManyToMany(targetEntity="Genre", inversedBy="items", cascade={"persist"}) |
||
107 | * @ORM\JoinTable(name="items_genres") |
||
108 | * |
||
109 | * @var \Doctrine\Common\Collections\ArrayCollection |
||
110 | */ |
||
111 | protected $genres; |
||
112 | |||
113 | /** |
||
114 | * Label list |
||
115 | * |
||
116 | * @ORM\ManyToMany(targetEntity="Label", inversedBy="items", cascade={"persist"}) |
||
117 | * @ORM\JoinTable(name="items_labels") |
||
118 | * |
||
119 | * @var \Doctrine\Common\Collections\ArrayCollection |
||
120 | */ |
||
121 | protected $labels; |
||
122 | |||
123 | /** |
||
124 | * Country |
||
125 | * |
||
126 | * @ORM\ManyToOne(targetEntity="Country", inversedBy="items", cascade={"persist"}) |
||
127 | * @ORM\JoinColumn(name="country", referencedColumnName="id") |
||
128 | * |
||
129 | * @var \AnimeDb\Bundle\CatalogBundle\Entity\Country |
||
130 | */ |
||
131 | protected $country; |
||
132 | |||
133 | /** |
||
134 | * Duration |
||
135 | * |
||
136 | * @ORM\Column(type="integer", nullable=true) |
||
137 | * @Assert\Type(type="integer", message="The value {{ value }} is not a valid {{ type }}.") |
||
138 | * |
||
139 | * @var integer |
||
140 | */ |
||
141 | protected $duration = 0; |
||
142 | |||
143 | /** |
||
144 | * Summary |
||
145 | * |
||
146 | * @ORM\Column(type="text", nullable=true) |
||
147 | * |
||
148 | * @var string |
||
149 | */ |
||
150 | protected $summary = ''; |
||
151 | |||
152 | /** |
||
153 | * Disk path |
||
154 | * |
||
155 | * @ORM\Column(type="string", length=256, nullable=true) |
||
156 | * |
||
157 | * @var string |
||
158 | */ |
||
159 | protected $path = ''; |
||
160 | |||
161 | /** |
||
162 | * Storage |
||
163 | * |
||
164 | * @ORM\ManyToOne(targetEntity="Storage", inversedBy="items", cascade={"persist"}) |
||
165 | * @ORM\JoinColumn(name="storage", referencedColumnName="id") |
||
166 | * |
||
167 | * @var \AnimeDb\Bundle\CatalogBundle\Entity\Storage |
||
168 | */ |
||
169 | protected $storage; |
||
170 | |||
171 | /** |
||
172 | * Episodes list |
||
173 | * |
||
174 | * @ORM\Column(type="text", nullable=true) |
||
175 | * |
||
176 | * @var string |
||
177 | */ |
||
178 | protected $episodes = ''; |
||
179 | |||
180 | /** |
||
181 | * Translate (subtitles and voice) |
||
182 | * |
||
183 | * @ORM\Column(type="string", length=256, nullable=true) |
||
184 | * |
||
185 | * @var string |
||
186 | */ |
||
187 | protected $translate = ''; |
||
188 | |||
189 | /** |
||
190 | * File info |
||
191 | * |
||
192 | * @ORM\Column(type="text", nullable=true) |
||
193 | * |
||
194 | * @var string |
||
195 | */ |
||
196 | protected $file_info = ''; |
||
197 | |||
198 | /** |
||
199 | * Source list |
||
200 | * |
||
201 | * @ORM\OneToMany(targetEntity="Source", mappedBy="item", cascade={"persist", "remove"}, orphanRemoval=true) |
||
202 | * |
||
203 | * @var \Doctrine\Common\Collections\ArrayCollection |
||
204 | */ |
||
205 | protected $sources; |
||
206 | |||
207 | /** |
||
208 | * Cover |
||
209 | * |
||
210 | * @ORM\Column(type="string", length=256, nullable=true) |
||
211 | * |
||
212 | * @var string |
||
213 | */ |
||
214 | protected $cover = ''; |
||
215 | |||
216 | /** |
||
217 | * Number of episodes |
||
218 | * |
||
219 | * @ORM\Column(type="string", length=5, nullable=true) |
||
220 | * @Assert\Regex( |
||
221 | * pattern="/^(\d{1,4}\+?)$/", |
||
222 | * message="The number of episodes should be a number and can contain a '+' to denote the continuation of production" |
||
223 | * ) |
||
224 | * |
||
225 | * @var string |
||
226 | */ |
||
227 | protected $episodes_number = ''; |
||
228 | |||
229 | /** |
||
230 | * Date add item |
||
231 | * |
||
232 | * @ORM\Column(type="datetime") |
||
233 | * |
||
234 | * @var \DateTime |
||
235 | */ |
||
236 | protected $date_add; |
||
237 | |||
238 | /** |
||
239 | * Date last update item |
||
240 | * |
||
241 | * @ORM\Column(type="datetime") |
||
242 | * |
||
243 | * @var \DateTime |
||
244 | */ |
||
245 | protected $date_update; |
||
246 | |||
247 | /** |
||
248 | * Image list |
||
249 | * |
||
250 | * @ORM\OneToMany(targetEntity="Image", mappedBy="item", cascade={"persist", "remove"}, orphanRemoval=true) |
||
251 | * |
||
252 | * @var \Doctrine\Common\Collections\ArrayCollection |
||
253 | */ |
||
254 | protected $images; |
||
255 | |||
256 | /** |
||
257 | * Rating |
||
258 | * |
||
259 | * @ORM\Column(type="integer", nullable=true) |
||
260 | * @Assert\Type(type="integer", message="The value {{ value }} is not a valid {{ type }}.") |
||
261 | * |
||
262 | * @var integer |
||
263 | */ |
||
264 | protected $rating = 0; |
||
265 | |||
266 | /** |
||
267 | * Studio |
||
268 | * |
||
269 | * @ORM\ManyToOne(targetEntity="Studio", inversedBy="items", cascade={"persist"}) |
||
270 | * @ORM\JoinColumn(name="studio", referencedColumnName="id") |
||
271 | * |
||
272 | * @var \AnimeDb\Bundle\CatalogBundle\Entity\Studio |
||
273 | */ |
||
274 | protected $studio; |
||
275 | |||
276 | /** |
||
277 | * Not cleared path |
||
278 | * |
||
279 | * @var string |
||
280 | */ |
||
281 | protected $not_cleared_path = ''; |
||
282 | |||
283 | /** |
||
284 | * Construct |
||
285 | */ |
||
286 | 116 | public function __construct() { |
|
295 | |||
296 | /** |
||
297 | * Get id |
||
298 | * |
||
299 | * @return integer |
||
300 | */ |
||
301 | 1 | public function getId() |
|
305 | |||
306 | /** |
||
307 | * Set name |
||
308 | * |
||
309 | * @param string $name |
||
310 | * |
||
311 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
312 | */ |
||
313 | 5 | public function setName($name) |
|
318 | |||
319 | /** |
||
320 | * Get name |
||
321 | * |
||
322 | * @return string |
||
323 | */ |
||
324 | 2 | public function getName() |
|
328 | |||
329 | /** |
||
330 | * Set date premiere |
||
331 | * |
||
332 | * @param \DateTime|null $date_premiere |
||
333 | * |
||
334 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
335 | */ |
||
336 | 1 | public function setDatePremiere(\DateTime $date_premiere = null) |
|
341 | |||
342 | /** |
||
343 | * Get date premiere |
||
344 | * |
||
345 | * @return \DateTime |
||
346 | */ |
||
347 | 1 | public function getDatePremiere() |
|
351 | |||
352 | /** |
||
353 | * Set date end |
||
354 | * |
||
355 | * @param \DateTime|null $date_end |
||
356 | * |
||
357 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
358 | */ |
||
359 | 1 | public function setDateEnd(\DateTime $date_end = null) |
|
364 | |||
365 | /** |
||
366 | * Get date end |
||
367 | * |
||
368 | * @return \DateTime|null |
||
369 | */ |
||
370 | 1 | public function getDateEnd() |
|
374 | |||
375 | /** |
||
376 | * Set duration |
||
377 | * |
||
378 | * @param integer $duration |
||
379 | * |
||
380 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
381 | */ |
||
382 | 1 | public function setDuration($duration) |
|
387 | |||
388 | /** |
||
389 | * Get duration |
||
390 | * |
||
391 | * @return integer |
||
392 | */ |
||
393 | 1 | public function getDuration() |
|
397 | |||
398 | /** |
||
399 | * Set summary |
||
400 | * |
||
401 | * @param string $summary |
||
402 | * |
||
403 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
404 | */ |
||
405 | 1 | public function setSummary($summary) |
|
410 | |||
411 | /** |
||
412 | * Get summary |
||
413 | * |
||
414 | * @return string |
||
415 | */ |
||
416 | 1 | public function getSummary() |
|
420 | |||
421 | /** |
||
422 | * Set path |
||
423 | * |
||
424 | * @param string $path |
||
425 | * |
||
426 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
427 | */ |
||
428 | 8 | public function setPath($path) |
|
438 | |||
439 | /** |
||
440 | * Get path |
||
441 | * |
||
442 | * @return string |
||
443 | */ |
||
444 | 6 | public function getPath() |
|
456 | |||
457 | /** |
||
458 | * Get real path |
||
459 | * |
||
460 | * Need for tests |
||
461 | * |
||
462 | * @return string |
||
463 | */ |
||
464 | 4 | public function getRealPath() |
|
468 | |||
469 | /** |
||
470 | * Set episodes |
||
471 | * |
||
472 | * @param string $episodes |
||
473 | * |
||
474 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
475 | */ |
||
476 | 1 | public function setEpisodes($episodes) |
|
481 | |||
482 | /** |
||
483 | * Get episodes |
||
484 | * |
||
485 | * @return string |
||
486 | */ |
||
487 | 1 | public function getEpisodes() |
|
491 | |||
492 | /** |
||
493 | * Set translate |
||
494 | * |
||
495 | * @param string $translate |
||
496 | * |
||
497 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
498 | */ |
||
499 | 1 | public function setTranslate($translate) |
|
504 | |||
505 | /** |
||
506 | * Get translate |
||
507 | * |
||
508 | * @return string |
||
509 | */ |
||
510 | 1 | public function getTranslate() |
|
514 | |||
515 | /** |
||
516 | * Set file info |
||
517 | * |
||
518 | * @param string $fileInfo |
||
519 | * |
||
520 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
521 | */ |
||
522 | 1 | public function setFileInfo($fileInfo) |
|
527 | |||
528 | /** |
||
529 | * Get file_info |
||
530 | * |
||
531 | * @return string |
||
532 | */ |
||
533 | 1 | public function getFileInfo() |
|
537 | |||
538 | /** |
||
539 | * Add name |
||
540 | * |
||
541 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Name $name |
||
542 | * |
||
543 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
544 | */ |
||
545 | View Code Duplication | public function addName(Name $name) |
|
|
|||
546 | { |
||
547 | $names = array_map('strval', $this->names->toArray()); |
||
548 | if (!in_array($name->getName(), $names)) { |
||
549 | $this->names->add($name); |
||
550 | $name->setItem($this); |
||
551 | } |
||
552 | return $this; |
||
553 | } |
||
554 | |||
555 | /** |
||
556 | * Remove name |
||
557 | * |
||
558 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Name $name |
||
559 | * |
||
560 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
561 | */ |
||
562 | public function removeName(Name $name) |
||
563 | { |
||
564 | if ($this->names->contains($name)) { |
||
565 | $this->names->removeElement($name); |
||
566 | $name->setItem(null); |
||
567 | } |
||
568 | return $this; |
||
569 | } |
||
570 | |||
571 | /** |
||
572 | * Get names |
||
573 | * |
||
574 | * @return \Doctrine\Common\Collections\Collection |
||
575 | */ |
||
576 | public function getNames() |
||
577 | { |
||
578 | return $this->names; |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * Set type |
||
583 | * |
||
584 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Type $type |
||
585 | * |
||
586 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
587 | */ |
||
588 | 2 | View Code Duplication | public function setType(Type $type = null) |
605 | |||
606 | /** |
||
607 | * Get type |
||
608 | * |
||
609 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Type |
||
610 | */ |
||
611 | 2 | public function getType() |
|
615 | |||
616 | /** |
||
617 | * Add genre |
||
618 | * |
||
619 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Genre $genre |
||
620 | * |
||
621 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
622 | */ |
||
623 | 2 | public function addGenre(Genre $genre) |
|
631 | |||
632 | /** |
||
633 | * Remove genre |
||
634 | * |
||
635 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Genre $genre |
||
636 | * |
||
637 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
638 | */ |
||
639 | 1 | public function removeGenre(Genre $genre) |
|
647 | |||
648 | /** |
||
649 | * Get genres |
||
650 | * |
||
651 | * @return \Doctrine\Common\Collections\Collection |
||
652 | */ |
||
653 | 2 | public function getGenres() |
|
657 | |||
658 | /** |
||
659 | * Add label |
||
660 | * |
||
661 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Label $label |
||
662 | * |
||
663 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
664 | */ |
||
665 | 1 | public function addLabel(Label $label) |
|
673 | |||
674 | /** |
||
675 | * Remove label |
||
676 | * |
||
677 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Label $label |
||
678 | * |
||
679 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
680 | */ |
||
681 | 1 | public function removeLabel(Label $label) |
|
689 | |||
690 | /** |
||
691 | * Get labels |
||
692 | * |
||
693 | * @return \Doctrine\Common\Collections\Collection |
||
694 | */ |
||
695 | 1 | public function getLabels() |
|
699 | |||
700 | /** |
||
701 | * Set country |
||
702 | * |
||
703 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Country $country |
||
704 | * |
||
705 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
706 | */ |
||
707 | 2 | View Code Duplication | public function setCountry(Country $country = null) |
724 | |||
725 | /** |
||
726 | * Get country |
||
727 | * |
||
728 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Country |
||
729 | */ |
||
730 | 2 | public function getCountry() |
|
734 | |||
735 | /** |
||
736 | * Set storage |
||
737 | * |
||
738 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Storage $storage |
||
739 | * |
||
740 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
741 | */ |
||
742 | 7 | View Code Duplication | public function setStorage(Storage $storage = null) |
760 | |||
761 | /** |
||
762 | * Get storage |
||
763 | * |
||
764 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Storage |
||
765 | */ |
||
766 | 10 | public function getStorage() |
|
770 | |||
771 | /** |
||
772 | * Set cover |
||
773 | * |
||
774 | * @param string $cover |
||
775 | * |
||
776 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
777 | */ |
||
778 | 1 | public function setCover($cover) |
|
783 | |||
784 | /** |
||
785 | * Get cover |
||
786 | * |
||
787 | * @return string |
||
788 | */ |
||
789 | 1 | public function getCover() |
|
793 | |||
794 | /** |
||
795 | * (non-PHPdoc) |
||
796 | * @see \AnimeDb\Bundle\AppBundle\Service\Downloader\Entity\BaseEntity::getFilename() |
||
797 | */ |
||
798 | 2 | public function getFilename() |
|
802 | |||
803 | /** |
||
804 | * (non-PHPdoc) |
||
805 | * @see \AnimeDb\Bundle\AppBundle\Service\Downloader\Entity\BaseEntity::setFilename() |
||
806 | */ |
||
807 | 2 | public function setFilename($filename) |
|
813 | |||
814 | /** |
||
815 | * Add source |
||
816 | * |
||
817 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Source $source |
||
818 | * |
||
819 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
820 | */ |
||
821 | View Code Duplication | public function addSource(Source $source) |
|
822 | { |
||
823 | $sources = array_map('strval', $this->sources->toArray()); |
||
824 | if (!in_array($source->getUrl(), $sources)) { |
||
825 | $this->sources->add($source); |
||
826 | $source->setItem($this); |
||
827 | } |
||
828 | return $this; |
||
829 | } |
||
830 | |||
831 | /** |
||
832 | * Remove source |
||
833 | * |
||
834 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Source $source |
||
835 | * |
||
836 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
837 | */ |
||
838 | public function removeSource(Source $source) |
||
839 | { |
||
840 | if ($this->sources->contains($source)) { |
||
841 | $this->sources->removeElement($source); |
||
842 | $source->setItem(null); |
||
843 | } |
||
844 | return $this; |
||
845 | } |
||
846 | |||
847 | /** |
||
848 | * Get sources |
||
849 | * |
||
850 | * @return \Doctrine\Common\Collections\Collection |
||
851 | */ |
||
852 | public function getSources() |
||
853 | { |
||
854 | return $this->sources; |
||
855 | } |
||
856 | |||
857 | /** |
||
858 | * Add image |
||
859 | * |
||
860 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Image $image |
||
861 | * |
||
862 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
863 | */ |
||
864 | View Code Duplication | public function addImage(Image $image) |
|
865 | { |
||
866 | $images = array_map('strval', $this->images->toArray()); |
||
867 | if (!in_array($image->getSource(), $images)) { |
||
868 | $this->images->add($image); |
||
869 | $image->setItem($this); |
||
870 | } |
||
871 | return $this; |
||
872 | } |
||
873 | |||
874 | /** |
||
875 | * Remove image |
||
876 | * |
||
877 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Image $image |
||
878 | * |
||
879 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
880 | */ |
||
881 | public function removeImage(Image $image) |
||
882 | { |
||
883 | if ($this->images->contains($image)) { |
||
884 | $this->images->removeElement($image); |
||
885 | $image->setItem(null); |
||
886 | } |
||
887 | return $this; |
||
888 | } |
||
889 | |||
890 | /** |
||
891 | * Get images |
||
892 | * |
||
893 | * @return \Doctrine\Common\Collections\Collection |
||
894 | */ |
||
895 | public function getImages() |
||
896 | { |
||
897 | return $this->images; |
||
898 | } |
||
899 | |||
900 | /** |
||
901 | * Set number of episodes |
||
902 | * |
||
903 | * @param string $episodes_number |
||
904 | * |
||
905 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
906 | */ |
||
907 | 1 | public function setEpisodesNumber($episodes_number) |
|
912 | |||
913 | /** |
||
914 | * Get number of episodes |
||
915 | * |
||
916 | * @return string |
||
917 | */ |
||
918 | 1 | public function getEpisodesNumber() |
|
922 | |||
923 | /** |
||
924 | * Set date add item |
||
925 | * |
||
926 | * @param \DateTime $date_add |
||
927 | * |
||
928 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
929 | */ |
||
930 | 1 | public function setDateAdd(\DateTime $date_add) |
|
935 | |||
936 | /** |
||
937 | * Get date add item |
||
938 | * |
||
939 | * @return \DateTime |
||
940 | */ |
||
941 | 1 | public function getDateAdd() |
|
945 | |||
946 | /** |
||
947 | * Set date last update item |
||
948 | * |
||
949 | * @param \DateTime $date_update |
||
950 | * |
||
951 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
952 | */ |
||
953 | 2 | public function setDateUpdate(\DateTime $date_update) |
|
958 | |||
959 | /** |
||
960 | * Get date last update item |
||
961 | * |
||
962 | * @return \DateTime |
||
963 | */ |
||
964 | 2 | public function getDateUpdate() |
|
968 | |||
969 | /** |
||
970 | * Set rating |
||
971 | * |
||
972 | * @param integer $rating |
||
973 | * |
||
974 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
975 | */ |
||
976 | 1 | public function setRating($rating) |
|
981 | |||
982 | /** |
||
983 | * Get rating |
||
984 | * |
||
985 | * @return integer |
||
986 | */ |
||
987 | 1 | public function getRating() |
|
991 | |||
992 | /** |
||
993 | * Set studio |
||
994 | * |
||
995 | * @param \AnimeDb\Bundle\CatalogBundle\Entity\Studio $studio |
||
996 | * |
||
997 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
998 | */ |
||
999 | 1 | View Code Duplication | public function setStudio(Studio $studio = null) |
1016 | |||
1017 | /** |
||
1018 | * Get studio |
||
1019 | * |
||
1020 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Studio |
||
1021 | */ |
||
1022 | 1 | public function getStudio() |
|
1026 | |||
1027 | /** |
||
1028 | * Change item date update |
||
1029 | * |
||
1030 | * @ORM\PreUpdate |
||
1031 | */ |
||
1032 | 1 | public function doChangeDateUpdate() |
|
1036 | |||
1037 | /** |
||
1038 | * Is valid path for current type |
||
1039 | * |
||
1040 | * @param \Symfony\Component\Validator\ExecutionContextInterface $context |
||
1041 | */ |
||
1042 | 4 | public function isPathValid(ExecutionContextInterface $context) |
|
1048 | |||
1049 | /** |
||
1050 | * Freeze item |
||
1051 | * |
||
1052 | * @param \Doctrine\Bundle\DoctrineBundle\Registry $doctrine |
||
1053 | * |
||
1054 | * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item |
||
1055 | */ |
||
1056 | 1 | public function freez(Registry $doctrine) |
|
1072 | |||
1073 | /** |
||
1074 | * Remove storage path in item path |
||
1075 | * |
||
1076 | * @ORM\PrePersist |
||
1077 | * @ORM\PreUpdate |
||
1078 | */ |
||
1079 | 8 | public function doClearPath() |
|
1091 | |||
1092 | /** |
||
1093 | * Get item name for url |
||
1094 | * |
||
1095 | * @return string |
||
1096 | */ |
||
1097 | 3 | public function getUrlName() |
|
1101 | |||
1102 | /** |
||
1103 | * To string |
||
1104 | * |
||
1105 | * @return string |
||
1106 | */ |
||
1107 | 1 | public function __toString() |
|
1111 | } |
||
1112 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.