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 |
||
| 28 | class ClassCategory extends \Eccube\Entity\AbstractEntity |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | 71 | public function __toString() |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @var int |
||
| 40 | * |
||
| 41 | * @ORM\Column(name="id", type="integer", options={"unsigned":true}) |
||
| 42 | * @ORM\Id |
||
| 43 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
| 44 | */ |
||
| 45 | private $id; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string |
||
| 49 | * |
||
| 50 | * @ORM\Column(name="backend_name", type="string", length=255, nullable=true) |
||
| 51 | */ |
||
| 52 | private $backend_name; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var string |
||
| 56 | * |
||
| 57 | * @ORM\Column(name="name", type="string", length=255) |
||
| 58 | */ |
||
| 59 | private $name; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @var int |
||
| 63 | * |
||
| 64 | * @ORM\Column(name="sort_no", type="integer") |
||
| 65 | */ |
||
| 66 | private $sort_no; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var boolean |
||
| 70 | * |
||
| 71 | * @ORM\Column(name="visible", type="boolean", options={"default":true}) |
||
| 72 | */ |
||
| 73 | private $visible; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @var \DateTime |
||
| 77 | * |
||
| 78 | * @ORM\Column(name="create_date", type="datetimetz") |
||
| 79 | */ |
||
| 80 | private $create_date; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var \DateTime |
||
| 84 | * |
||
| 85 | * @ORM\Column(name="update_date", type="datetimetz") |
||
| 86 | */ |
||
| 87 | private $update_date; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var \Eccube\Entity\ClassName |
||
| 91 | * |
||
| 92 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\ClassName", inversedBy="ClassCategories") |
||
| 93 | * @ORM\JoinColumns({ |
||
| 94 | * @ORM\JoinColumn(name="class_name_id", referencedColumnName="id") |
||
| 95 | * }) |
||
| 96 | */ |
||
| 97 | private $ClassName; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var \Eccube\Entity\Member |
||
| 101 | * |
||
| 102 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member") |
||
| 103 | * @ORM\JoinColumns({ |
||
| 104 | * @ORM\JoinColumn(name="creator_id", referencedColumnName="id") |
||
| 105 | * }) |
||
| 106 | */ |
||
| 107 | 107 | private $Creator; |
|
| 108 | |||
| 109 | 107 | /** |
|
| 110 | * Get id. |
||
| 111 | * |
||
| 112 | * @return int |
||
| 113 | */ |
||
| 114 | public function getId() |
||
| 118 | |||
| 119 | 21 | /** |
|
| 120 | * Set backend_name. |
||
| 121 | 21 | * |
|
| 122 | * @param string $backendName |
||
| 123 | 21 | * |
|
| 124 | * @return ClassCategory |
||
| 125 | */ |
||
| 126 | public function setBackendName($backendName) |
||
| 132 | |||
| 133 | 284 | /** |
|
| 134 | * Get backend_name. |
||
| 135 | * |
||
| 136 | * @return string |
||
| 137 | */ |
||
| 138 | public function getBackendName() |
||
| 142 | |||
| 143 | 21 | /** |
|
| 144 | * Set name. |
||
| 145 | 21 | * |
|
| 146 | * @param string $name |
||
| 147 | 21 | * |
|
| 148 | * @return ClassCategory |
||
| 149 | */ |
||
| 150 | public function setName($name) |
||
| 156 | |||
| 157 | 9 | /** |
|
| 158 | * Get name. |
||
| 159 | * |
||
| 160 | * @return string |
||
| 161 | */ |
||
| 162 | public function getName() |
||
| 166 | |||
| 167 | 18 | /** |
|
| 168 | * Set sortNo. |
||
| 169 | 18 | * |
|
| 170 | * @param int $sortNo |
||
| 171 | 18 | * |
|
| 172 | * @return ClassCategory |
||
| 173 | */ |
||
| 174 | public function setSortNo($sortNo) |
||
| 180 | |||
| 181 | /** |
||
| 182 | * Get sortNo. |
||
| 183 | * |
||
| 184 | * @return int |
||
| 185 | */ |
||
| 186 | public function getSortNo() |
||
| 190 | |||
| 191 | 21 | /** |
|
| 192 | * Set createDate. |
||
| 193 | 21 | * |
|
| 194 | * @param \DateTime $createDate |
||
| 195 | 21 | * |
|
| 196 | * @return ClassCategory |
||
| 197 | */ |
||
| 198 | public function setCreateDate($createDate) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Get createDate. |
||
| 207 | * |
||
| 208 | * @return \DateTime |
||
| 209 | */ |
||
| 210 | public function getCreateDate() |
||
| 214 | |||
| 215 | 20 | /** |
|
| 216 | * Set updateDate. |
||
| 217 | 20 | * |
|
| 218 | * @param \DateTime $updateDate |
||
| 219 | 20 | * |
|
| 220 | * @return ClassCategory |
||
| 221 | */ |
||
| 222 | public function setUpdateDate($updateDate) |
||
| 228 | |||
| 229 | 273 | /** |
|
| 230 | * Get updateDate. |
||
| 231 | * |
||
| 232 | * @return \DateTime |
||
| 233 | */ |
||
| 234 | public function getUpdateDate() |
||
| 238 | |||
| 239 | 10 | /** |
|
| 240 | * Set className. |
||
| 241 | 10 | * |
|
| 242 | * @param \Eccube\Entity\ClassName|null $className |
||
| 243 | 10 | * |
|
| 244 | * @return ClassCategory |
||
| 245 | */ |
||
| 246 | public function setClassName(\Eccube\Entity\ClassName $className = null) |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Get className. |
||
| 255 | * |
||
| 256 | * @return \Eccube\Entity\ClassName|null |
||
| 257 | */ |
||
| 258 | public function getClassName() |
||
| 262 | |||
| 263 | 18 | /** |
|
| 264 | * Set creator. |
||
| 265 | 18 | * |
|
| 266 | * @param \Eccube\Entity\Member|null $creator |
||
| 267 | 18 | * |
|
| 268 | * @return ClassCategory |
||
| 269 | */ |
||
| 270 | public function setCreator(\Eccube\Entity\Member $creator = null) |
||
| 276 | |||
| 277 | 98 | /** |
|
| 278 | * Get creator. |
||
| 279 | * |
||
| 280 | * @return \Eccube\Entity\Member|null |
||
| 281 | */ |
||
| 282 | public function getCreator() |
||
| 286 | |||
| 287 | /** |
||
| 288 | * Set visible |
||
| 289 | * |
||
| 290 | * @param boolean $visible |
||
| 291 | * |
||
| 292 | * @return ClassCategory |
||
| 293 | */ |
||
| 294 | public function setVisible($visible) |
||
| 300 | |||
| 301 | /** |
||
| 302 | * Is the visibility visible? |
||
| 303 | * |
||
| 304 | * @return boolean |
||
| 305 | */ |
||
| 306 | public function isVisible() |
||
| 310 | } |
||
| 311 | } |
||
| 312 |