| Total Complexity | 66 |
| Total Lines | 373 |
| 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 | |||
| 52 | /** |
||
| 53 | * @var ObjectStorage<FieldValue> |
||
| 54 | * @Extbase\ORM\Cascade("remove") |
||
| 55 | * @Extbase\ORM\Lazy |
||
| 56 | */ |
||
| 57 | protected ObjectStorage $fieldValues; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Registration constructor. |
||
| 61 | */ |
||
| 62 | public function __construct() |
||
| 63 | { |
||
| 64 | $this->initializeObject(); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Initialize all ObjectStorages as fetching an entity from the DB does not use the constructor |
||
| 69 | */ |
||
| 70 | public function initializeObject(): void |
||
| 71 | { |
||
| 72 | $this->fieldValues = $this->fieldValues ?? new ObjectStorage(); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function getFirstname(): string |
||
| 76 | { |
||
| 77 | return $this->firstname; |
||
| 78 | } |
||
| 79 | |||
| 80 | public function setFirstname(string $firstname): void |
||
| 81 | { |
||
| 82 | $this->firstname = $firstname; |
||
| 83 | } |
||
| 84 | |||
| 85 | public function getLastname(): string |
||
| 86 | { |
||
| 87 | return $this->lastname; |
||
| 88 | } |
||
| 89 | |||
| 90 | public function setLastname(string $lastname): void |
||
| 91 | { |
||
| 92 | $this->lastname = $lastname; |
||
| 93 | } |
||
| 94 | |||
| 95 | public function getTitle(): string |
||
| 96 | { |
||
| 97 | return $this->title; |
||
| 98 | } |
||
| 99 | |||
| 100 | public function setTitle(string $title): void |
||
| 101 | { |
||
| 102 | $this->title = $title; |
||
| 103 | } |
||
| 104 | |||
| 105 | public function getCompany(): string |
||
| 106 | { |
||
| 107 | return $this->company; |
||
| 108 | } |
||
| 109 | |||
| 110 | public function setCompany(string $company): void |
||
| 111 | { |
||
| 112 | $this->company = $company; |
||
| 113 | } |
||
| 114 | |||
| 115 | public function getAddress(): string |
||
| 116 | { |
||
| 117 | return $this->address; |
||
| 118 | } |
||
| 119 | |||
| 120 | public function setAddress(string $address): void |
||
| 121 | { |
||
| 122 | $this->address = $address; |
||
| 123 | } |
||
| 124 | |||
| 125 | public function getZip(): string |
||
| 126 | { |
||
| 127 | return $this->zip; |
||
| 128 | } |
||
| 129 | |||
| 130 | public function setZip(string $zip): void |
||
| 131 | { |
||
| 132 | $this->zip = $zip; |
||
| 133 | } |
||
| 134 | |||
| 135 | public function getCity(): string |
||
| 136 | { |
||
| 137 | return $this->city; |
||
| 138 | } |
||
| 139 | |||
| 140 | public function setCity(string $city): void |
||
| 141 | { |
||
| 142 | $this->city = $city; |
||
| 143 | } |
||
| 144 | |||
| 145 | public function getCountry(): string |
||
| 146 | { |
||
| 147 | return $this->country; |
||
| 148 | } |
||
| 149 | |||
| 150 | public function setCountry(string $country): void |
||
| 151 | { |
||
| 152 | $this->country = $country; |
||
| 153 | } |
||
| 154 | |||
| 155 | public function getPhone(): string |
||
| 156 | { |
||
| 157 | return $this->phone; |
||
| 158 | } |
||
| 159 | |||
| 160 | public function setPhone(string $phone): void |
||
| 161 | { |
||
| 162 | $this->phone = $phone; |
||
| 163 | } |
||
| 164 | |||
| 165 | public function getEmail(): string |
||
| 168 | } |
||
| 169 | |||
| 170 | public function setEmail(string $email): void |
||
| 171 | { |
||
| 172 | $this->email = trim($email); |
||
| 173 | } |
||
| 174 | |||
| 175 | public function isIgnoreNotifications(): bool |
||
| 178 | } |
||
| 179 | |||
| 180 | public function getIgnoreNotifications(): bool |
||
| 181 | { |
||
| 182 | return $this->ignoreNotifications; |
||
| 183 | } |
||
| 184 | |||
| 185 | public function setIgnoreNotifications(bool $ignoreNotifications): void |
||
| 186 | { |
||
| 187 | $this->ignoreNotifications = $ignoreNotifications; |
||
| 188 | } |
||
| 189 | |||
| 190 | public function getGender(): string |
||
| 191 | { |
||
| 192 | return $this->gender; |
||
| 193 | } |
||
| 194 | |||
| 195 | public function setGender(string $gender): void |
||
| 196 | { |
||
| 197 | $this->gender = $gender; |
||
| 198 | } |
||
| 199 | |||
| 200 | public function setDateOfBirth(?DateTime $dateOfBirth): void |
||
| 201 | { |
||
| 202 | $this->dateOfBirth = $dateOfBirth; |
||
| 203 | } |
||
| 204 | |||
| 205 | public function getDateOfBirth(): ?DateTime |
||
| 206 | { |
||
| 207 | return $this->dateOfBirth; |
||
| 208 | } |
||
| 209 | |||
| 210 | public function getAccepttc(): bool |
||
| 211 | { |
||
| 212 | return $this->accepttc; |
||
| 213 | } |
||
| 214 | |||
| 215 | public function setAccepttc(bool $accepttc): void |
||
| 216 | { |
||
| 217 | $this->accepttc = $accepttc; |
||
| 218 | } |
||
| 219 | |||
| 220 | public function getConfirmed(): bool |
||
| 221 | { |
||
| 222 | return $this->confirmed; |
||
| 223 | } |
||
| 224 | |||
| 225 | public function setConfirmed(bool $confirmed): void |
||
| 226 | { |
||
| 227 | $this->confirmed = $confirmed; |
||
| 228 | } |
||
| 229 | |||
| 230 | public function isConfirmed(): bool |
||
| 231 | { |
||
| 232 | return $this->confirmed; |
||
| 233 | } |
||
| 234 | |||
| 235 | public function getPaid(): bool |
||
| 236 | { |
||
| 237 | return $this->paid; |
||
| 238 | } |
||
| 239 | |||
| 240 | public function setPaid(bool $paid): void |
||
| 241 | { |
||
| 242 | $this->paid = $paid; |
||
| 243 | } |
||
| 244 | |||
| 245 | public function isPaid(): bool |
||
| 246 | { |
||
| 247 | return $this->paid; |
||
| 248 | } |
||
| 249 | |||
| 250 | public function setEvent(?Event $event): void |
||
| 251 | { |
||
| 252 | $this->event = $event; |
||
| 253 | } |
||
| 254 | |||
| 255 | public function getEvent(): ?Event |
||
| 256 | { |
||
| 257 | return $this->event; |
||
| 258 | } |
||
| 259 | |||
| 260 | public function setMainRegistration(?Registration $registration): void |
||
| 261 | { |
||
| 262 | $this->mainRegistration = $registration; |
||
| 263 | } |
||
| 264 | |||
| 265 | public function getMainRegistration(): ?Registration |
||
| 266 | { |
||
| 267 | return $this->mainRegistration; |
||
| 268 | } |
||
| 269 | |||
| 270 | public function setNotes(string $notes): void |
||
| 271 | { |
||
| 272 | $this->notes = $notes; |
||
| 273 | } |
||
| 274 | |||
| 275 | public function getNotes(): string |
||
| 276 | { |
||
| 277 | return $this->notes; |
||
| 278 | } |
||
| 279 | |||
| 280 | public function setConfirmationUntil(?DateTime $confirmationUntil): void |
||
| 281 | { |
||
| 282 | $this->confirmationUntil = $confirmationUntil; |
||
| 283 | } |
||
| 284 | |||
| 285 | public function getConfirmationUntil(): ?DateTime |
||
| 286 | { |
||
| 287 | return $this->confirmationUntil; |
||
| 288 | } |
||
| 289 | |||
| 290 | public function getRegistrationDate(): ?DateTime |
||
| 291 | { |
||
| 292 | return $this->registrationDate; |
||
| 293 | } |
||
| 294 | |||
| 295 | public function setRegistrationDate(?DateTime $registrationDate): void |
||
| 296 | { |
||
| 297 | $this->registrationDate = $registrationDate; |
||
| 298 | } |
||
| 299 | |||
| 300 | public function setHidden(bool $hidden): void |
||
| 301 | { |
||
| 302 | $this->hidden = $hidden; |
||
| 303 | } |
||
| 304 | |||
| 305 | public function getHidden(): bool |
||
| 306 | { |
||
| 307 | return $this->hidden; |
||
| 308 | } |
||
| 309 | |||
| 310 | public function getAmountOfRegistrations(): int |
||
| 311 | { |
||
| 312 | return $this->amountOfRegistrations; |
||
| 313 | } |
||
| 314 | |||
| 315 | public function setAmountOfRegistrations(int $amountOfRegistrations): void |
||
| 316 | { |
||
| 317 | $this->amountOfRegistrations = $amountOfRegistrations; |
||
| 318 | } |
||
| 319 | |||
| 320 | public function getLanguage(): string |
||
| 321 | { |
||
| 322 | return $this->language; |
||
| 323 | } |
||
| 324 | |||
| 325 | public function setLanguage(string $language): void |
||
| 326 | { |
||
| 327 | $this->language = $language; |
||
| 328 | } |
||
| 329 | |||
| 330 | public function getCaptcha(): string |
||
| 331 | { |
||
| 332 | return $this->captcha; |
||
| 333 | } |
||
| 334 | |||
| 335 | public function setCaptcha(string $captcha): void |
||
| 336 | { |
||
| 337 | $this->captcha = $captcha; |
||
| 338 | } |
||
| 339 | |||
| 340 | public function getFeUser(): ?FrontendUser |
||
| 341 | { |
||
| 342 | return $this->feUser; |
||
| 343 | } |
||
| 344 | |||
| 345 | public function setFeUser(?FrontendUser $feUser): void |
||
| 346 | { |
||
| 347 | $this->feUser = $feUser; |
||
| 348 | } |
||
| 349 | |||
| 350 | public function getPaymentmethod(): string |
||
| 351 | { |
||
| 352 | return $this->paymentmethod; |
||
| 353 | } |
||
| 354 | |||
| 355 | public function setPaymentmethod(string $paymentmethod): void |
||
| 356 | { |
||
| 357 | $this->paymentmethod = $paymentmethod; |
||
| 358 | } |
||
| 359 | |||
| 360 | public function getPaymentReference(): string |
||
| 361 | { |
||
| 362 | return $this->paymentReference; |
||
| 363 | } |
||
| 364 | |||
| 365 | public function setPaymentReference(string $paymentReference): void |
||
| 366 | { |
||
| 367 | $this->paymentReference = $paymentReference; |
||
| 368 | } |
||
| 369 | |||
| 370 | public function getWaitlist(): bool |
||
| 373 | } |
||
| 374 | |||
| 375 | public function setWaitlist(bool $waitlist): void |
||
| 376 | { |
||
| 377 | $this->waitlist = $waitlist; |
||
| 378 | } |
||
| 379 | |||
| 380 | public function getFieldValues(): ?ObjectStorage |
||
| 381 | { |
||
| 382 | return $this->fieldValues; |
||
| 383 | } |
||
| 384 | |||
| 385 | public function setFieldValues(?ObjectStorage $fieldValues): void |
||
| 386 | { |
||
| 387 | $this->fieldValues = $fieldValues; |
||
| 388 | } |
||
| 389 | |||
| 390 | public function getFullname(): string |
||
| 391 | { |
||
| 392 | return $this->firstname . ' ' . $this->lastname; |
||
| 393 | } |
||
| 394 | } |
||
| 395 |
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