| Total Complexity | 70 |
| Total Lines | 398 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Registration 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 Registration, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class Registration extends AbstractEntity |
||
| 21 | { |
||
| 22 | protected string $firstname = ''; |
||
| 23 | protected string $lastname = ''; |
||
| 24 | protected string $title = ''; |
||
| 25 | protected string $company = ''; |
||
| 26 | protected string $address = ''; |
||
| 27 | protected string $zip = ''; |
||
| 28 | protected string $city = ''; |
||
| 29 | protected string $country = ''; |
||
| 30 | protected string $phone = ''; |
||
| 31 | protected string $email = ''; |
||
| 32 | protected bool $ignoreNotifications = false; |
||
| 33 | protected string $gender = ''; |
||
| 34 | protected ?DateTime $dateOfBirth = null; |
||
| 35 | protected bool $accepttc = false; |
||
| 36 | protected bool $confirmed = false; |
||
| 37 | protected bool $paid = false; |
||
| 38 | protected string $notes = ''; |
||
| 39 | protected ?Event $event = null; |
||
| 40 | protected ?Registration $mainRegistration = null; |
||
| 41 | protected ?DateTime $confirmationUntil = null; |
||
| 42 | protected ?DateTime $registrationDate = null; |
||
| 43 | protected bool $hidden = false; |
||
| 44 | protected int $amountOfRegistrations = 1; |
||
| 45 | protected string $language = ''; |
||
| 46 | protected string $captcha = ''; |
||
| 47 | protected ?FrontendUser $feUser = null; |
||
| 48 | protected string $paymentmethod = ''; |
||
| 49 | protected string $paymentReference = ''; |
||
| 50 | protected bool $waitlist = false; |
||
| 51 | protected float $price = 0.0; |
||
| 52 | protected ?PriceOption $priceOption = null; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var ObjectStorage<FieldValue> |
||
| 56 | * @Extbase\ORM\Cascade("remove") |
||
| 57 | * @Extbase\ORM\Lazy |
||
| 58 | */ |
||
| 59 | protected ObjectStorage $fieldValues; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Registration constructor. |
||
| 63 | */ |
||
| 64 | public function __construct() |
||
| 65 | { |
||
| 66 | $this->initializeObject(); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Initialize all ObjectStorages as fetching an entity from the DB does not use the constructor |
||
| 71 | */ |
||
| 72 | public function initializeObject(): void |
||
| 73 | { |
||
| 74 | $this->fieldValues = $this->fieldValues ?? new ObjectStorage(); |
||
| 75 | } |
||
| 76 | |||
| 77 | public function getFirstname(): string |
||
| 78 | { |
||
| 79 | return $this->firstname; |
||
| 80 | } |
||
| 81 | |||
| 82 | public function setFirstname(string $firstname): void |
||
| 83 | { |
||
| 84 | $this->firstname = $firstname; |
||
| 85 | } |
||
| 86 | |||
| 87 | public function getLastname(): string |
||
| 88 | { |
||
| 89 | return $this->lastname; |
||
| 90 | } |
||
| 91 | |||
| 92 | public function setLastname(string $lastname): void |
||
| 93 | { |
||
| 94 | $this->lastname = $lastname; |
||
| 95 | } |
||
| 96 | |||
| 97 | public function getTitle(): string |
||
| 98 | { |
||
| 99 | return $this->title; |
||
| 100 | } |
||
| 101 | |||
| 102 | public function setTitle(string $title): void |
||
| 103 | { |
||
| 104 | $this->title = $title; |
||
| 105 | } |
||
| 106 | |||
| 107 | public function getCompany(): string |
||
| 108 | { |
||
| 109 | return $this->company; |
||
| 110 | } |
||
| 111 | |||
| 112 | public function setCompany(string $company): void |
||
| 113 | { |
||
| 114 | $this->company = $company; |
||
| 115 | } |
||
| 116 | |||
| 117 | public function getAddress(): string |
||
| 118 | { |
||
| 119 | return $this->address; |
||
| 120 | } |
||
| 121 | |||
| 122 | public function setAddress(string $address): void |
||
| 123 | { |
||
| 124 | $this->address = $address; |
||
| 125 | } |
||
| 126 | |||
| 127 | public function getZip(): string |
||
| 128 | { |
||
| 129 | return $this->zip; |
||
| 130 | } |
||
| 131 | |||
| 132 | public function setZip(string $zip): void |
||
| 133 | { |
||
| 134 | $this->zip = $zip; |
||
| 135 | } |
||
| 136 | |||
| 137 | public function getCity(): string |
||
| 138 | { |
||
| 139 | return $this->city; |
||
| 140 | } |
||
| 141 | |||
| 142 | public function setCity(string $city): void |
||
| 143 | { |
||
| 144 | $this->city = $city; |
||
| 145 | } |
||
| 146 | |||
| 147 | public function getCountry(): string |
||
| 148 | { |
||
| 149 | return $this->country; |
||
| 150 | } |
||
| 151 | |||
| 152 | public function setCountry(string $country): void |
||
| 153 | { |
||
| 154 | $this->country = $country; |
||
| 155 | } |
||
| 156 | |||
| 157 | public function getPhone(): string |
||
| 158 | { |
||
| 159 | return $this->phone; |
||
| 160 | } |
||
| 161 | |||
| 162 | public function setPhone(string $phone): void |
||
| 163 | { |
||
| 164 | $this->phone = $phone; |
||
| 165 | } |
||
| 166 | |||
| 167 | public function getEmail(): string |
||
| 170 | } |
||
| 171 | |||
| 172 | public function setEmail(string $email): void |
||
| 173 | { |
||
| 174 | $this->email = trim($email); |
||
| 175 | } |
||
| 176 | |||
| 177 | public function isIgnoreNotifications(): bool |
||
| 180 | } |
||
| 181 | |||
| 182 | public function getIgnoreNotifications(): bool |
||
| 183 | { |
||
| 184 | return $this->ignoreNotifications; |
||
| 185 | } |
||
| 186 | |||
| 187 | public function setIgnoreNotifications(bool $ignoreNotifications): void |
||
| 188 | { |
||
| 189 | $this->ignoreNotifications = $ignoreNotifications; |
||
| 190 | } |
||
| 191 | |||
| 192 | public function getGender(): string |
||
| 193 | { |
||
| 194 | return $this->gender; |
||
| 195 | } |
||
| 196 | |||
| 197 | public function setGender(string $gender): void |
||
| 198 | { |
||
| 199 | $this->gender = $gender; |
||
| 200 | } |
||
| 201 | |||
| 202 | public function setDateOfBirth(?DateTime $dateOfBirth): void |
||
| 203 | { |
||
| 204 | $this->dateOfBirth = $dateOfBirth; |
||
| 205 | } |
||
| 206 | |||
| 207 | public function getDateOfBirth(): ?DateTime |
||
| 208 | { |
||
| 209 | return $this->dateOfBirth; |
||
| 210 | } |
||
| 211 | |||
| 212 | public function getAccepttc(): bool |
||
| 213 | { |
||
| 214 | return $this->accepttc; |
||
| 215 | } |
||
| 216 | |||
| 217 | public function setAccepttc(bool $accepttc): void |
||
| 218 | { |
||
| 219 | $this->accepttc = $accepttc; |
||
| 220 | } |
||
| 221 | |||
| 222 | public function getConfirmed(): bool |
||
| 223 | { |
||
| 224 | return $this->confirmed; |
||
| 225 | } |
||
| 226 | |||
| 227 | public function setConfirmed(bool $confirmed): void |
||
| 228 | { |
||
| 229 | $this->confirmed = $confirmed; |
||
| 230 | } |
||
| 231 | |||
| 232 | public function isConfirmed(): bool |
||
| 233 | { |
||
| 234 | return $this->confirmed; |
||
| 235 | } |
||
| 236 | |||
| 237 | public function getPaid(): bool |
||
| 238 | { |
||
| 239 | return $this->paid; |
||
| 240 | } |
||
| 241 | |||
| 242 | public function setPaid(bool $paid): void |
||
| 243 | { |
||
| 244 | $this->paid = $paid; |
||
| 245 | } |
||
| 246 | |||
| 247 | public function isPaid(): bool |
||
| 248 | { |
||
| 249 | return $this->paid; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function setEvent(?Event $event): void |
||
| 253 | { |
||
| 254 | $this->event = $event; |
||
| 255 | } |
||
| 256 | |||
| 257 | public function getEvent(): ?Event |
||
| 258 | { |
||
| 259 | return $this->event; |
||
| 260 | } |
||
| 261 | |||
| 262 | public function setMainRegistration(?Registration $registration): void |
||
| 263 | { |
||
| 264 | $this->mainRegistration = $registration; |
||
| 265 | } |
||
| 266 | |||
| 267 | public function getMainRegistration(): ?Registration |
||
| 268 | { |
||
| 269 | return $this->mainRegistration; |
||
| 270 | } |
||
| 271 | |||
| 272 | public function setNotes(string $notes): void |
||
| 273 | { |
||
| 274 | $this->notes = $notes; |
||
| 275 | } |
||
| 276 | |||
| 277 | public function getNotes(): string |
||
| 278 | { |
||
| 279 | return $this->notes; |
||
| 280 | } |
||
| 281 | |||
| 282 | public function setConfirmationUntil(?DateTime $confirmationUntil): void |
||
| 283 | { |
||
| 284 | $this->confirmationUntil = $confirmationUntil; |
||
| 285 | } |
||
| 286 | |||
| 287 | public function getConfirmationUntil(): ?DateTime |
||
| 288 | { |
||
| 289 | return $this->confirmationUntil; |
||
| 290 | } |
||
| 291 | |||
| 292 | public function getRegistrationDate(): ?DateTime |
||
| 293 | { |
||
| 294 | return $this->registrationDate; |
||
| 295 | } |
||
| 296 | |||
| 297 | public function setRegistrationDate(?DateTime $registrationDate): void |
||
| 298 | { |
||
| 299 | $this->registrationDate = $registrationDate; |
||
| 300 | } |
||
| 301 | |||
| 302 | public function setHidden(bool $hidden): void |
||
| 303 | { |
||
| 304 | $this->hidden = $hidden; |
||
| 305 | } |
||
| 306 | |||
| 307 | public function getHidden(): bool |
||
| 308 | { |
||
| 309 | return $this->hidden; |
||
| 310 | } |
||
| 311 | |||
| 312 | public function getAmountOfRegistrations(): int |
||
| 313 | { |
||
| 314 | return $this->amountOfRegistrations; |
||
| 315 | } |
||
| 316 | |||
| 317 | public function setAmountOfRegistrations(int $amountOfRegistrations): void |
||
| 318 | { |
||
| 319 | $this->amountOfRegistrations = $amountOfRegistrations; |
||
| 320 | } |
||
| 321 | |||
| 322 | public function getLanguage(): string |
||
| 323 | { |
||
| 324 | return $this->language; |
||
| 325 | } |
||
| 326 | |||
| 327 | public function setLanguage(string $language): void |
||
| 328 | { |
||
| 329 | $this->language = $language; |
||
| 330 | } |
||
| 331 | |||
| 332 | public function getCaptcha(): string |
||
| 333 | { |
||
| 334 | return $this->captcha; |
||
| 335 | } |
||
| 336 | |||
| 337 | public function setCaptcha(string $captcha): void |
||
| 338 | { |
||
| 339 | $this->captcha = $captcha; |
||
| 340 | } |
||
| 341 | |||
| 342 | public function getFeUser(): ?FrontendUser |
||
| 343 | { |
||
| 344 | return $this->feUser; |
||
| 345 | } |
||
| 346 | |||
| 347 | public function setFeUser(?FrontendUser $feUser): void |
||
| 348 | { |
||
| 349 | $this->feUser = $feUser; |
||
| 350 | } |
||
| 351 | |||
| 352 | public function getPaymentmethod(): string |
||
| 353 | { |
||
| 354 | return $this->paymentmethod; |
||
| 355 | } |
||
| 356 | |||
| 357 | public function setPaymentmethod(string $paymentmethod): void |
||
| 358 | { |
||
| 359 | $this->paymentmethod = $paymentmethod; |
||
| 360 | } |
||
| 361 | |||
| 362 | public function getPaymentReference(): string |
||
| 363 | { |
||
| 364 | return $this->paymentReference; |
||
| 365 | } |
||
| 366 | |||
| 367 | public function setPaymentReference(string $paymentReference): void |
||
| 368 | { |
||
| 369 | $this->paymentReference = $paymentReference; |
||
| 370 | } |
||
| 371 | |||
| 372 | public function getWaitlist(): bool |
||
| 375 | } |
||
| 376 | |||
| 377 | public function setWaitlist(bool $waitlist): void |
||
| 378 | { |
||
| 379 | $this->waitlist = $waitlist; |
||
| 380 | } |
||
| 381 | |||
| 382 | /** |
||
| 383 | * @return ObjectStorage<FieldValue>|null |
||
| 384 | */ |
||
| 385 | public function getFieldValues(): ?ObjectStorage |
||
| 386 | { |
||
| 387 | return $this->fieldValues; |
||
| 388 | } |
||
| 389 | |||
| 390 | public function setFieldValues(?ObjectStorage $fieldValues): void |
||
| 391 | { |
||
| 392 | $this->fieldValues = $fieldValues; |
||
| 393 | } |
||
| 394 | |||
| 395 | public function getFullname(): string |
||
| 396 | { |
||
| 397 | return $this->firstname . ' ' . $this->lastname; |
||
| 398 | } |
||
| 399 | |||
| 400 | public function getPrice(): float |
||
| 401 | { |
||
| 402 | return $this->price; |
||
| 403 | } |
||
| 404 | |||
| 405 | public function setPrice(float $price): void |
||
| 406 | { |
||
| 407 | $this->price = $price; |
||
| 408 | } |
||
| 409 | |||
| 410 | public function getPriceOption(): ?PriceOption |
||
| 413 | } |
||
| 414 | |||
| 415 | public function setPriceOption(?PriceOption $priceOption): void |
||
| 416 | { |
||
| 417 | $this->priceOption = $priceOption; |
||
| 418 | } |
||
| 419 | } |
||
| 420 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths