| Total Complexity | 42 |
| Total Lines | 520 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like FrontendUser 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 FrontendUser, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 24 | class FrontendUser extends AbstractEntity |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | protected $username = ''; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | protected $password = ''; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup> |
||
| 38 | */ |
||
| 39 | protected $usergroup; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | protected $name = ''; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var string |
||
| 48 | */ |
||
| 49 | protected $firstName = ''; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var string |
||
| 53 | */ |
||
| 54 | protected $middleName = ''; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @var string |
||
| 58 | */ |
||
| 59 | protected $lastName = ''; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | protected $address = ''; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | protected $telephone = ''; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var string |
||
| 73 | */ |
||
| 74 | protected $fax = ''; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var string |
||
| 78 | */ |
||
| 79 | protected $email = ''; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @var string |
||
| 83 | */ |
||
| 84 | protected $title = ''; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @var string |
||
| 88 | */ |
||
| 89 | protected $zip = ''; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var string |
||
| 93 | */ |
||
| 94 | protected $city = ''; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var string |
||
| 98 | */ |
||
| 99 | protected $country = ''; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @var string |
||
| 103 | */ |
||
| 104 | protected $www = ''; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string |
||
| 108 | */ |
||
| 109 | protected $company = ''; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
| 113 | */ |
||
| 114 | protected $image; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @var \DateTime|null |
||
| 118 | */ |
||
| 119 | protected $lastlogin; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Constructs a new Front-End User |
||
| 123 | * |
||
| 124 | * @param string $username |
||
| 125 | * @param string $password |
||
| 126 | */ |
||
| 127 | public function __construct($username = '', $password = '') |
||
| 128 | { |
||
| 129 | $this->username = $username; |
||
| 130 | $this->password = $password; |
||
| 131 | $this->usergroup = new ObjectStorage(); |
||
| 132 | $this->image = new ObjectStorage(); |
||
| 133 | } |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Called again with initialize object, as fetching an entity from the DB does not use the constructor |
||
| 137 | */ |
||
| 138 | public function initializeObject() |
||
| 139 | { |
||
| 140 | $this->usergroup = $this->usergroup ?? new ObjectStorage(); |
||
| 141 | $this->image = $this->image ?? new ObjectStorage(); |
||
| 142 | } |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Sets the username value |
||
| 146 | * |
||
| 147 | * @param string $username |
||
| 148 | */ |
||
| 149 | public function setUsername($username) |
||
| 150 | { |
||
| 151 | $this->username = $username; |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Returns the username value |
||
| 156 | * |
||
| 157 | * @return string |
||
| 158 | */ |
||
| 159 | public function getUsername() |
||
| 160 | { |
||
| 161 | return $this->username; |
||
| 162 | } |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Sets the password value |
||
| 166 | * |
||
| 167 | * @param string $password |
||
| 168 | */ |
||
| 169 | public function setPassword($password) |
||
| 170 | { |
||
| 171 | $this->password = $password; |
||
| 172 | } |
||
| 173 | |||
| 174 | /** |
||
| 175 | * Returns the password value |
||
| 176 | * |
||
| 177 | * @return string |
||
| 178 | */ |
||
| 179 | public function getPassword() |
||
| 180 | { |
||
| 181 | return $this->password; |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Sets the usergroups. Keep in mind that the property is called "usergroup" |
||
| 186 | * although it can hold several usergroups. |
||
| 187 | * |
||
| 188 | * @param ObjectStorage $usergroup |
||
| 189 | */ |
||
| 190 | public function setUsergroup(ObjectStorage $usergroup) |
||
| 191 | { |
||
| 192 | $this->usergroup = $usergroup; |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Adds a usergroup to the frontend user |
||
| 197 | * |
||
| 198 | * @param FrontendUserGroup $usergroup |
||
| 199 | */ |
||
| 200 | public function addUsergroup(FrontendUserGroup $usergroup) |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Removes a usergroup from the frontend user |
||
| 207 | * |
||
| 208 | * @param FrontendUserGroup $usergroup |
||
| 209 | */ |
||
| 210 | public function removeUsergroup(FrontendUserGroup $usergroup) |
||
| 211 | { |
||
| 212 | $this->usergroup->detach($usergroup); |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Returns the usergroups. Keep in mind that the property is called "usergroup" |
||
| 217 | * although it can hold several usergroups. |
||
| 218 | * |
||
| 219 | * @return ObjectStorage An object storage containing the usergroup |
||
| 220 | */ |
||
| 221 | public function getUsergroup() |
||
| 222 | { |
||
| 223 | return $this->usergroup; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Sets the name value |
||
| 228 | * |
||
| 229 | * @param string $name |
||
| 230 | */ |
||
| 231 | public function setName($name) |
||
| 232 | { |
||
| 233 | $this->name = $name; |
||
| 234 | } |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Returns the name value |
||
| 238 | * |
||
| 239 | * @return string |
||
| 240 | */ |
||
| 241 | public function getName() |
||
| 242 | { |
||
| 243 | return $this->name; |
||
| 244 | } |
||
| 245 | |||
| 246 | /** |
||
| 247 | * Sets the firstName value |
||
| 248 | * |
||
| 249 | * @param string $firstName |
||
| 250 | */ |
||
| 251 | public function setFirstName($firstName) |
||
| 252 | { |
||
| 253 | $this->firstName = $firstName; |
||
| 254 | } |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Returns the firstName value |
||
| 258 | * |
||
| 259 | * @return string |
||
| 260 | */ |
||
| 261 | public function getFirstName() |
||
| 262 | { |
||
| 263 | return $this->firstName; |
||
| 264 | } |
||
| 265 | |||
| 266 | /** |
||
| 267 | * Sets the middleName value |
||
| 268 | * |
||
| 269 | * @param string $middleName |
||
| 270 | */ |
||
| 271 | public function setMiddleName($middleName) |
||
| 272 | { |
||
| 273 | $this->middleName = $middleName; |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Returns the middleName value |
||
| 278 | * |
||
| 279 | * @return string |
||
| 280 | */ |
||
| 281 | public function getMiddleName() |
||
| 282 | { |
||
| 283 | return $this->middleName; |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * Sets the lastName value |
||
| 288 | * |
||
| 289 | * @param string $lastName |
||
| 290 | */ |
||
| 291 | public function setLastName($lastName) |
||
| 292 | { |
||
| 293 | $this->lastName = $lastName; |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * Returns the lastName value |
||
| 298 | * |
||
| 299 | * @return string |
||
| 300 | */ |
||
| 301 | public function getLastName() |
||
| 302 | { |
||
| 303 | return $this->lastName; |
||
| 304 | } |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Sets the address value |
||
| 308 | * |
||
| 309 | * @param string $address |
||
| 310 | */ |
||
| 311 | public function setAddress($address) |
||
| 312 | { |
||
| 313 | $this->address = $address; |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Returns the address value |
||
| 318 | * |
||
| 319 | * @return string |
||
| 320 | */ |
||
| 321 | public function getAddress() |
||
| 322 | { |
||
| 323 | return $this->address; |
||
| 324 | } |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Sets the telephone value |
||
| 328 | * |
||
| 329 | * @param string $telephone |
||
| 330 | */ |
||
| 331 | public function setTelephone($telephone) |
||
| 332 | { |
||
| 333 | $this->telephone = $telephone; |
||
| 334 | } |
||
| 335 | |||
| 336 | /** |
||
| 337 | * Returns the telephone value |
||
| 338 | * |
||
| 339 | * @return string |
||
| 340 | */ |
||
| 341 | public function getTelephone() |
||
| 342 | { |
||
| 343 | return $this->telephone; |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Sets the fax value |
||
| 348 | * |
||
| 349 | * @param string $fax |
||
| 350 | */ |
||
| 351 | public function setFax($fax) |
||
| 352 | { |
||
| 353 | $this->fax = $fax; |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Returns the fax value |
||
| 358 | * |
||
| 359 | * @return string |
||
| 360 | */ |
||
| 361 | public function getFax() |
||
| 362 | { |
||
| 363 | return $this->fax; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Sets the email value |
||
| 368 | * |
||
| 369 | * @param string $email |
||
| 370 | */ |
||
| 371 | public function setEmail($email) |
||
| 372 | { |
||
| 373 | $this->email = $email; |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Returns the email value |
||
| 378 | * |
||
| 379 | * @return string |
||
| 380 | */ |
||
| 381 | public function getEmail() |
||
| 382 | { |
||
| 383 | return $this->email; |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Sets the title value |
||
| 388 | * |
||
| 389 | * @param string $title |
||
| 390 | */ |
||
| 391 | public function setTitle($title) |
||
| 392 | { |
||
| 393 | $this->title = $title; |
||
| 394 | } |
||
| 395 | |||
| 396 | /** |
||
| 397 | * Returns the title value |
||
| 398 | * |
||
| 399 | * @return string |
||
| 400 | */ |
||
| 401 | public function getTitle() |
||
| 402 | { |
||
| 403 | return $this->title; |
||
| 404 | } |
||
| 405 | |||
| 406 | /** |
||
| 407 | * Sets the zip value |
||
| 408 | * |
||
| 409 | * @param string $zip |
||
| 410 | */ |
||
| 411 | public function setZip($zip) |
||
| 412 | { |
||
| 413 | $this->zip = $zip; |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Returns the zip value |
||
| 418 | * |
||
| 419 | * @return string |
||
| 420 | */ |
||
| 421 | public function getZip() |
||
| 422 | { |
||
| 423 | return $this->zip; |
||
| 424 | } |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Sets the city value |
||
| 428 | * |
||
| 429 | * @param string $city |
||
| 430 | */ |
||
| 431 | public function setCity($city) |
||
| 432 | { |
||
| 433 | $this->city = $city; |
||
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * Returns the city value |
||
| 438 | * |
||
| 439 | * @return string |
||
| 440 | */ |
||
| 441 | public function getCity() |
||
| 442 | { |
||
| 443 | return $this->city; |
||
| 444 | } |
||
| 445 | |||
| 446 | /** |
||
| 447 | * Sets the country value |
||
| 448 | * |
||
| 449 | * @param string $country |
||
| 450 | */ |
||
| 451 | public function setCountry($country) |
||
| 452 | { |
||
| 453 | $this->country = $country; |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * Returns the country value |
||
| 458 | * |
||
| 459 | * @return string |
||
| 460 | */ |
||
| 461 | public function getCountry() |
||
| 462 | { |
||
| 463 | return $this->country; |
||
| 464 | } |
||
| 465 | |||
| 466 | /** |
||
| 467 | * Sets the www value |
||
| 468 | * |
||
| 469 | * @param string $www |
||
| 470 | */ |
||
| 471 | public function setWww($www) |
||
| 472 | { |
||
| 473 | $this->www = $www; |
||
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Returns the www value |
||
| 478 | * |
||
| 479 | * @return string |
||
| 480 | */ |
||
| 481 | public function getWww() |
||
| 482 | { |
||
| 483 | return $this->www; |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Sets the company value |
||
| 488 | * |
||
| 489 | * @param string $company |
||
| 490 | */ |
||
| 491 | public function setCompany($company) |
||
| 492 | { |
||
| 493 | $this->company = $company; |
||
| 494 | } |
||
| 495 | |||
| 496 | /** |
||
| 497 | * Returns the company value |
||
| 498 | * |
||
| 499 | * @return string |
||
| 500 | */ |
||
| 501 | public function getCompany() |
||
| 502 | { |
||
| 503 | return $this->company; |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * Sets the image value |
||
| 508 | * |
||
| 509 | * @param ObjectStorage $image |
||
| 510 | */ |
||
| 511 | public function setImage(ObjectStorage $image) |
||
| 512 | { |
||
| 513 | $this->image = $image; |
||
| 514 | } |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Gets the image value |
||
| 518 | * |
||
| 519 | * @return ObjectStorage |
||
| 520 | */ |
||
| 521 | public function getImage() |
||
| 524 | } |
||
| 525 | |||
| 526 | /** |
||
| 527 | * Sets the lastlogin value |
||
| 528 | * |
||
| 529 | * @param \DateTime $lastlogin |
||
| 530 | */ |
||
| 531 | public function setLastlogin(\DateTime $lastlogin) |
||
| 532 | { |
||
| 533 | $this->lastlogin = $lastlogin; |
||
| 534 | } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * Returns the lastlogin value |
||
| 538 | * |
||
| 539 | * @return \DateTime |
||
| 540 | */ |
||
| 541 | public function getLastlogin() |
||
| 542 | { |
||
| 543 | return $this->lastlogin; |
||
| 544 | } |
||
| 545 | } |
||
| 546 |