| Total Complexity | 40 |
| Total Lines | 520 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like MetadataObject 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 MetadataObject, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class MetadataObject extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements MetadataMandatoryInterface |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * name |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $name = ''; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * displayName |
||
| 32 | * |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $displayName = ''; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * maxIteration |
||
| 39 | * |
||
| 40 | * @var integer |
||
| 41 | */ |
||
| 42 | protected $maxIteration = 0; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * mandatory |
||
| 46 | * |
||
| 47 | * @var string |
||
| 48 | */ |
||
| 49 | protected $mandatory = ''; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * mapping |
||
| 53 | * |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | protected $mapping = ''; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * inputField |
||
| 60 | * |
||
| 61 | * @var integer |
||
| 62 | */ |
||
| 63 | protected $inputField = 0; |
||
| 64 | |||
| 65 | |||
| 66 | const input = 0; |
||
| 67 | const textarea = 1; |
||
| 68 | const select = 2; |
||
| 69 | const checkbox = 3; |
||
| 70 | const hidden = 4; |
||
| 71 | const INPUTDROPDOWN = 100; |
||
| 72 | |||
| 73 | const INPUT_DATA_TYPE_REGEXP = "REGEXP"; |
||
| 74 | const INPUT_DATA_TYPE_DATE = "DATE"; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * dataType |
||
| 78 | * |
||
| 79 | * @var string |
||
| 80 | */ |
||
| 81 | protected $dataType; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * modsExtension |
||
| 85 | * |
||
| 86 | * @var boolean |
||
| 87 | */ |
||
| 88 | protected $modsExtension = false; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * inputOptionList |
||
| 92 | * |
||
| 93 | * @var \EWW\Dpf\Domain\Model\InputOptionList |
||
| 94 | */ |
||
| 95 | protected $inputOptionList = null; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * fillOutService |
||
| 99 | * |
||
| 100 | * @var string |
||
| 101 | */ |
||
| 102 | protected $fillOutService = ''; |
||
| 103 | |||
| 104 | const FILL_OUT_SERVICE_URN = 'urn'; |
||
| 105 | const FILL_OUT_SERVICE_GND = 'gnd'; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var string |
||
| 109 | */ |
||
| 110 | protected $gndFieldUid = ''; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * accessRestrictionRoles |
||
| 114 | * |
||
| 115 | * @var string |
||
| 116 | */ |
||
| 117 | protected $accessRestrictionRoles = ''; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * consent |
||
| 121 | * |
||
| 122 | * @var boolean |
||
| 123 | */ |
||
| 124 | protected $consent; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * defaultValue |
||
| 128 | * |
||
| 129 | * @var string |
||
| 130 | */ |
||
| 131 | protected $defaultValue; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * validation |
||
| 135 | * |
||
| 136 | * @var string |
||
| 137 | */ |
||
| 138 | protected $validation = ''; |
||
| 139 | |||
| 140 | |||
| 141 | /** |
||
| 142 | * max input length |
||
| 143 | * |
||
| 144 | * @var integer |
||
| 145 | */ |
||
| 146 | protected $maxInputLength = 0; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Embargo field option |
||
| 150 | * |
||
| 151 | * @var boolean |
||
| 152 | */ |
||
| 153 | protected $embargo; |
||
| 154 | |||
| 155 | |||
| 156 | /** |
||
| 157 | * Returns the name |
||
| 158 | * |
||
| 159 | * @return string $name |
||
| 160 | */ |
||
| 161 | public function getName() |
||
| 162 | { |
||
| 163 | return $this->name; |
||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Sets the name |
||
| 168 | * |
||
| 169 | * @param string $name |
||
| 170 | * @return void |
||
| 171 | */ |
||
| 172 | public function setName($name) |
||
| 173 | { |
||
| 174 | $this->name = $name; |
||
| 175 | } |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Returns the displayName |
||
| 179 | * |
||
| 180 | * @return string $displayName |
||
| 181 | */ |
||
| 182 | public function getDisplayName() |
||
| 183 | { |
||
| 184 | return $this->displayName; |
||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Sets the displayName |
||
| 189 | * |
||
| 190 | * @param string $displayName |
||
| 191 | * @return void |
||
| 192 | */ |
||
| 193 | public function setDisplayName($displayName) |
||
| 194 | { |
||
| 195 | $this->displayName = $displayName; |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Returns the maxIteration |
||
| 200 | * |
||
| 201 | * @return integer $maxIteration |
||
| 202 | */ |
||
| 203 | public function getMaxIteration() |
||
| 204 | { |
||
| 205 | return $this->maxIteration; |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * Sets the maxIteration |
||
| 210 | * |
||
| 211 | * @param integer $maxIteration |
||
| 212 | * @return void |
||
| 213 | */ |
||
| 214 | public function setMaxIteration($maxIteration) |
||
| 215 | { |
||
| 216 | $this->maxIteration = $maxIteration; |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Returns the mandatory |
||
| 221 | * |
||
| 222 | * @return string $mandatory |
||
| 223 | */ |
||
| 224 | public function getMandatory() |
||
| 225 | { |
||
| 226 | return $this->mandatory; |
||
| 227 | } |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Sets the mandatory |
||
| 231 | * |
||
| 232 | * @param string $mandatory |
||
| 233 | * @return void |
||
| 234 | */ |
||
| 235 | public function setMandatory($mandatory) |
||
| 236 | { |
||
| 237 | $this->mandatory = $mandatory; |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Returns the modsExtension |
||
| 242 | * |
||
| 243 | * @return boolean $modsExtension |
||
| 244 | */ |
||
| 245 | public function getModsExtension() |
||
| 246 | { |
||
| 247 | return $this->modsExtension; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Sets the modsExtension |
||
| 252 | * |
||
| 253 | * @param boolean $modsExtension |
||
| 254 | * @return void |
||
| 255 | */ |
||
| 256 | public function setModsExtension($modsExtension) |
||
| 257 | { |
||
| 258 | $this->modsExtension = $modsExtension; |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Returns the boolean state of modsExtension |
||
| 263 | * |
||
| 264 | * @return boolean |
||
| 265 | */ |
||
| 266 | public function isModsExtension() |
||
| 267 | { |
||
| 268 | return $this->modsExtension; |
||
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Returns the mapping |
||
| 273 | * |
||
| 274 | * @return string $mapping |
||
| 275 | */ |
||
| 276 | public function getMapping() |
||
| 277 | { |
||
| 278 | return $this->mapping; |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * Sets the mapping |
||
| 283 | * |
||
| 284 | * @param string $mapping |
||
| 285 | * @return void |
||
| 286 | */ |
||
| 287 | public function setMapping($mapping) |
||
| 288 | { |
||
| 289 | $this->mapping = $mapping; |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Returns the relative mapping |
||
| 294 | * |
||
| 295 | * @return string $relativeMapping |
||
| 296 | */ |
||
| 297 | public function getRelativeMapping() |
||
| 298 | { |
||
| 299 | $modsRegExp = "/^.*?mods:mods/i"; |
||
| 300 | $mapping = preg_replace($modsRegExp, "", $this->mapping); |
||
| 301 | return trim($mapping, " /"); |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Returns the inputField |
||
| 306 | * |
||
| 307 | * @return integer $inputField |
||
| 308 | */ |
||
| 309 | public function getInputField() |
||
| 310 | { |
||
| 311 | return $this->inputField; |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Sets the inputField |
||
| 316 | * |
||
| 317 | * @param integer $inputField |
||
| 318 | * @return void |
||
| 319 | */ |
||
| 320 | public function setInputField($inputField) |
||
| 321 | { |
||
| 322 | $this->inputField = $inputField; |
||
| 323 | } |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Returns always NULL because an Object never has children. |
||
| 327 | * |
||
| 328 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject |
||
| 329 | */ |
||
| 330 | public function getChildren() |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Returns the inputOptionList |
||
| 337 | * |
||
| 338 | * @return \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList |
||
| 339 | */ |
||
| 340 | public function getInputOptionList() |
||
| 341 | { |
||
| 342 | return $this->inputOptionList; |
||
| 343 | } |
||
| 344 | |||
| 345 | /** |
||
| 346 | * Sets the inputOptionList |
||
| 347 | * |
||
| 348 | * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList |
||
| 349 | * @return void |
||
| 350 | */ |
||
| 351 | public function setInputOptionList(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList) |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Returns the fillOutService |
||
| 358 | * |
||
| 359 | * @return string $fillOutService |
||
| 360 | */ |
||
| 361 | public function getFillOutService() |
||
| 362 | { |
||
| 363 | return $this->fillOutService; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Sets the fillOutService |
||
| 368 | * |
||
| 369 | * @param string $fillOutService |
||
| 370 | * @return void |
||
| 371 | */ |
||
| 372 | public function setFillOutService($fillOutService) |
||
| 373 | { |
||
| 374 | $this->fillOutService = $fillOutService; |
||
| 375 | } |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Returns the accessRestrictionRoles |
||
| 379 | * |
||
| 380 | * @return array $accessRestrictionRoles |
||
| 381 | */ |
||
| 382 | public function getAccessRestrictionRoles() |
||
| 383 | { |
||
| 384 | if ($this->accessRestrictionRoles) { |
||
| 385 | return array_map('trim', explode(',', $this->accessRestrictionRoles)); |
||
| 386 | } else { |
||
| 387 | return array(); |
||
| 388 | } |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Sets the accessRestrictionRoles |
||
| 393 | * |
||
| 394 | * @param array $accessRestrictionRoles |
||
| 395 | * @return void |
||
| 396 | */ |
||
| 397 | public function setAccessRestrictionRoles($accessRestrictionRoles) |
||
| 398 | { |
||
| 399 | $this->accessRestrictionRoles = implode(',', $accessRestrictionRoles); |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Returns the consent |
||
| 404 | * |
||
| 405 | * @return boolean $consent |
||
| 406 | */ |
||
| 407 | public function getConsent() |
||
| 408 | { |
||
| 409 | return $this->consent; |
||
| 410 | } |
||
| 411 | |||
| 412 | /** |
||
| 413 | * Sets the consent |
||
| 414 | * |
||
| 415 | * @param boolean $consent |
||
| 416 | * @return void |
||
| 417 | */ |
||
| 418 | public function setConsent($consent) |
||
| 419 | { |
||
| 420 | $this->consent = $consent; |
||
| 421 | } |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Returns the defaultValue |
||
| 425 | * |
||
| 426 | * @return string $defaultValue |
||
| 427 | */ |
||
| 428 | public function getDefaultValue() |
||
| 429 | { |
||
| 430 | return $this->defaultValue; |
||
| 431 | } |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Sets the defaultValue |
||
| 435 | * |
||
| 436 | * @param string $defaultValue |
||
| 437 | * @return void |
||
| 438 | */ |
||
| 439 | public function setDefaultValue($defaultValue) |
||
| 440 | { |
||
| 441 | $this->defaultValue = $defaultValue; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Returns the validation |
||
| 446 | * |
||
| 447 | * @return string $validation |
||
| 448 | */ |
||
| 449 | public function getValidation() |
||
| 450 | { |
||
| 451 | return $this->validation; |
||
| 452 | } |
||
| 453 | |||
| 454 | /** |
||
| 455 | * Sets the validation |
||
| 456 | * |
||
| 457 | * @param string $validation |
||
| 458 | * @return void |
||
| 459 | */ |
||
| 460 | public function setValidation($validation) |
||
| 461 | { |
||
| 462 | $this->validation = $validation; |
||
| 463 | } |
||
| 464 | |||
| 465 | /** |
||
| 466 | * Returns the dataType |
||
| 467 | * |
||
| 468 | * @return string $dataType |
||
| 469 | */ |
||
| 470 | public function getDataType() |
||
| 471 | { |
||
| 472 | return $this->dataType; |
||
| 473 | } |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Sets the dataType |
||
| 477 | * |
||
| 478 | * @param string $dataType |
||
| 479 | * @return void |
||
| 480 | */ |
||
| 481 | public function setDataType($dataType) |
||
| 482 | { |
||
| 483 | $this->dataType = $dataType; |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * @return string |
||
| 488 | */ |
||
| 489 | public function getGndFieldUid() |
||
| 490 | { |
||
| 491 | return $this->gndFieldUid; |
||
| 492 | } |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @param string $gndFieldUid |
||
| 496 | */ |
||
| 497 | public function setGndFieldUid($gndFieldUid) |
||
| 498 | { |
||
| 499 | $this->gndFieldUid = $gndFieldUid; |
||
| 500 | } |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @return integer |
||
| 504 | */ |
||
| 505 | public function getMaxInputLength() |
||
| 515 | } |
||
| 516 | } |
||
| 517 | |||
| 518 | /** |
||
| 519 | * @return integer |
||
| 520 | */ |
||
| 521 | public function setMaxInputLength($maxInputLength) |
||
| 522 | { |
||
| 523 | $this->maxInputLength = $maxInputLength; |
||
| 524 | } |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @return bool |
||
| 528 | */ |
||
| 529 | public function getEmbargo(): bool |
||
| 532 | } |
||
| 533 | |||
| 534 | /** |
||
| 535 | * @param bool $embargo |
||
| 536 | */ |
||
| 537 | public function setEmbargo(bool $embargo) |
||
| 538 | { |
||
| 539 | $this->embargo = $embargo; |
||
| 540 | } |
||
| 541 | |||
| 542 | |||
| 543 | |||
| 544 | } |
||
| 545 |