| Total Complexity | 40 |
| Total Lines | 325 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Article 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.
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 Article, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | class Article |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @ORM\Id() |
||
| 17 | * @ORM\GeneratedValue() |
||
| 18 | * @ORM\Column(type="integer") |
||
| 19 | */ |
||
| 20 | private $id; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @ORM\Column(type="string", length=255) |
||
| 24 | */ |
||
| 25 | private $artnum; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @ORM\Column(type="integer", nullable=true) |
||
| 29 | */ |
||
| 30 | private $parentid; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @ORM\Column(type="integer", nullable=true) |
||
| 34 | */ |
||
| 35 | private $asy_packaging; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @ORM\Column(type="integer", nullable=true) |
||
| 39 | */ |
||
| 40 | private $asy_min_order; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 44 | */ |
||
| 45 | private $asy_installation; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 49 | */ |
||
| 50 | private $title; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 54 | */ |
||
| 55 | private $shortdesc; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @ORM\Column(type="text", nullable=true) |
||
| 59 | */ |
||
| 60 | private $longdesc; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 64 | */ |
||
| 65 | private $unitname; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 69 | */ |
||
| 70 | private $asy_deltext_standard_1; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 74 | */ |
||
| 75 | private $asy_deltext_standard_schweiz; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 79 | */ |
||
| 80 | private $asy_deltext_standard_2; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 84 | */ |
||
| 85 | private $alphabytes_variantenmerkmale; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 89 | */ |
||
| 90 | private $asy_deltext_standard; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @ORM\OneToMany(targetEntity=Object2attribute::class, mappedBy="object") |
||
| 94 | */ |
||
| 95 | private $attribute; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 99 | */ |
||
| 100 | private $varname; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @ORM\Column(type="string", length=255, nullable=true) |
||
| 104 | */ |
||
| 105 | private $varselect; |
||
| 106 | |||
| 107 | public function __construct() |
||
| 108 | { |
||
| 109 | $this->attribute = new ArrayCollection(); |
||
| 110 | } |
||
| 111 | |||
| 112 | public function getId(): ?int |
||
| 113 | { |
||
| 114 | return $this->id; |
||
| 115 | } |
||
| 116 | |||
| 117 | public function getArtnum(): ?string |
||
| 118 | { |
||
| 119 | return $this->artnum; |
||
| 120 | } |
||
| 121 | |||
| 122 | public function setArtnum(string $artnum): self |
||
| 123 | { |
||
| 124 | $this->artnum = $artnum; |
||
| 125 | |||
| 126 | return $this; |
||
| 127 | } |
||
| 128 | |||
| 129 | public function getParentid(): ?int |
||
| 130 | { |
||
| 131 | return $this->parentid; |
||
| 132 | } |
||
| 133 | |||
| 134 | public function setParentid(?int $parentid): self |
||
| 135 | { |
||
| 136 | $this->parentid = $parentid; |
||
| 137 | |||
| 138 | return $this; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function getAsyPackaging(): ?int |
||
| 142 | { |
||
| 143 | return $this->asy_packaging; |
||
| 144 | } |
||
| 145 | |||
| 146 | public function setAsyPackaging(?int $asy_packaging): self |
||
| 147 | { |
||
| 148 | $this->asy_packaging = $asy_packaging; |
||
| 149 | |||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function getAsyMinOrder(): ?int |
||
| 154 | { |
||
| 155 | return $this->asy_min_order; |
||
| 156 | } |
||
| 157 | |||
| 158 | public function setAsyMinOrder(?int $asy_min_order): self |
||
| 159 | { |
||
| 160 | $this->asy_min_order = $asy_min_order; |
||
| 161 | |||
| 162 | return $this; |
||
| 163 | } |
||
| 164 | |||
| 165 | public function getAsyInstallation(): ?string |
||
| 166 | { |
||
| 167 | return $this->asy_installation; |
||
| 168 | } |
||
| 169 | |||
| 170 | public function setAsyInstallation(?string $asy_installation): self |
||
| 171 | { |
||
| 172 | $this->asy_installation = $asy_installation; |
||
| 173 | |||
| 174 | return $this; |
||
| 175 | } |
||
| 176 | |||
| 177 | public function getTitle(): ?string |
||
| 178 | { |
||
| 179 | return $this->title; |
||
| 180 | } |
||
| 181 | |||
| 182 | public function setTitle(?string $title): self |
||
| 187 | } |
||
| 188 | |||
| 189 | public function getShortdesc(): ?string |
||
| 190 | { |
||
| 191 | return $this->shortdesc; |
||
| 192 | } |
||
| 193 | |||
| 194 | public function setShortdesc(?string $shortdesc): self |
||
| 195 | { |
||
| 196 | $this->shortdesc = $shortdesc; |
||
| 197 | |||
| 198 | return $this; |
||
| 199 | } |
||
| 200 | |||
| 201 | public function getLongdesc(): ?string |
||
| 202 | { |
||
| 203 | return $this->longdesc; |
||
| 204 | } |
||
| 205 | |||
| 206 | public function setLongdesc(?string $longdesc): self |
||
| 207 | { |
||
| 208 | $this->longdesc = $longdesc; |
||
| 209 | |||
| 210 | return $this; |
||
| 211 | } |
||
| 212 | |||
| 213 | public function getUnitname(): ?string |
||
| 214 | { |
||
| 215 | return $this->unitname; |
||
| 216 | } |
||
| 217 | |||
| 218 | public function setUnitname(?string $unitname): self |
||
| 219 | { |
||
| 220 | $this->unitname = $unitname; |
||
| 221 | |||
| 222 | return $this; |
||
| 223 | } |
||
| 224 | |||
| 225 | public function getAsyDeltextStandard1(): ?string |
||
| 226 | { |
||
| 227 | return $this->asy_deltext_standard_1; |
||
| 228 | } |
||
| 229 | |||
| 230 | public function setAsyDeltextStandard1(?string $asy_deltext_standard_1): self |
||
| 231 | { |
||
| 232 | $this->asy_deltext_standard_1 = $asy_deltext_standard_1; |
||
| 233 | |||
| 234 | return $this; |
||
| 235 | } |
||
| 236 | |||
| 237 | public function getAsyDeltextStandardSchweiz(): ?string |
||
| 238 | { |
||
| 239 | return $this->asy_deltext_standard_schweiz; |
||
| 240 | } |
||
| 241 | |||
| 242 | public function setAsyDeltextStandardSchweiz(?string $asy_deltext_standard_schweiz): self |
||
| 243 | { |
||
| 244 | $this->asy_deltext_standard_schweiz = $asy_deltext_standard_schweiz; |
||
| 245 | |||
| 246 | return $this; |
||
| 247 | } |
||
| 248 | |||
| 249 | public function getAsyDeltextStandard2(): ?string |
||
| 250 | { |
||
| 251 | return $this->asy_deltext_standard_2; |
||
| 252 | } |
||
| 253 | |||
| 254 | public function setAsyDeltextStandard2(?string $asy_deltext_standard_2): self |
||
| 255 | { |
||
| 256 | $this->asy_deltext_standard_2 = $asy_deltext_standard_2; |
||
| 257 | |||
| 258 | return $this; |
||
| 259 | } |
||
| 260 | |||
| 261 | public function getAlphabytesVariantenmerkmale(): ?string |
||
| 262 | { |
||
| 263 | return $this->alphabytes_variantenmerkmale; |
||
| 264 | } |
||
| 265 | |||
| 266 | public function setAlphabytesVariantenmerkmale(?string $alphabytes_variantenmerkmale): self |
||
| 267 | { |
||
| 268 | $this->alphabytes_variantenmerkmale = $alphabytes_variantenmerkmale; |
||
| 269 | |||
| 270 | return $this; |
||
| 271 | } |
||
| 272 | |||
| 273 | public function getAsyDeltextStandard(): ?string |
||
| 274 | { |
||
| 275 | return $this->asy_deltext_standard; |
||
| 276 | } |
||
| 277 | |||
| 278 | public function setAsyDeltextStandard(?string $asy_deltext_standard): self |
||
| 279 | { |
||
| 280 | $this->asy_deltext_standard = $asy_deltext_standard; |
||
| 281 | |||
| 282 | return $this; |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @return Collection|Object2attribute[] |
||
| 287 | */ |
||
| 288 | public function getAttribute(): Collection |
||
| 291 | } |
||
| 292 | |||
| 293 | public function addAttribute(Object2attribute $attribute): self |
||
| 301 | } |
||
| 302 | |||
| 303 | public function removeAttribute(Object2attribute $attribute): self |
||
| 304 | { |
||
| 314 | } |
||
| 315 | |||
| 316 | public function getVarname(): ?string |
||
| 317 | { |
||
| 318 | return $this->varname; |
||
| 319 | } |
||
| 320 | |||
| 321 | public function setVarname(?string $varname): self |
||
| 326 | } |
||
| 327 | |||
| 328 | public function getVarselect(): ?string |
||
| 329 | { |
||
| 330 | return $this->varselect; |
||
| 331 | } |
||
| 332 | |||
| 333 | public function setVarselect(?string $varselect): self |
||
| 334 | { |
||
| 335 | $this->varselect = $varselect; |
||
| 336 | |||
| 337 | return $this; |
||
| 338 | } |
||
| 339 | } |
||
| 340 |