Total Complexity | 64 |
Total Lines | 790 |
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 | * @var string |
||
67 | */ |
||
68 | protected $objectType = ''; |
||
69 | /** |
||
70 | * depositLicense |
||
71 | * |
||
72 | * @var int |
||
73 | */ |
||
74 | protected $depositLicense = ''; |
||
75 | |||
76 | /** |
||
77 | * JSON mapping |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | protected $jsonMapping = ''; |
||
82 | |||
83 | const input = 0; |
||
84 | const textarea = 1; |
||
85 | const select = 2; |
||
86 | const checkbox = 3; |
||
87 | const hidden = 4; |
||
88 | const textareaMarkdown = 10; |
||
89 | const INPUTDROPDOWN = 100; |
||
90 | |||
91 | const INPUT_DATA_TYPE_REGEXP = "REGEXP"; |
||
92 | const INPUT_DATA_TYPE_DATE = "DATE"; |
||
93 | |||
94 | /** |
||
95 | * dataType |
||
96 | * |
||
97 | * @var string |
||
98 | */ |
||
99 | protected $dataType; |
||
100 | |||
101 | /** |
||
102 | * modsExtension |
||
103 | * |
||
104 | * @var boolean |
||
105 | */ |
||
106 | protected $modsExtension = false; |
||
107 | |||
108 | /** |
||
109 | * inputOptionList |
||
110 | * |
||
111 | * @var \EWW\Dpf\Domain\Model\InputOptionList |
||
112 | */ |
||
113 | protected $inputOptionList = null; |
||
114 | |||
115 | /** |
||
116 | * fillOutService |
||
117 | * |
||
118 | * @var string |
||
119 | */ |
||
120 | protected $fillOutService = ''; |
||
121 | |||
122 | const FILL_OUT_SERVICE_URN = 'urn'; |
||
123 | const FILL_OUT_SERVICE_GND = 'gnd'; |
||
124 | |||
125 | /** |
||
126 | * @var string |
||
127 | */ |
||
128 | protected $gndFieldUid = ''; |
||
129 | |||
130 | /** |
||
131 | * accessRestrictionRoles |
||
132 | * |
||
133 | * @var string |
||
134 | */ |
||
135 | protected $accessRestrictionRoles = ''; |
||
136 | |||
137 | /** |
||
138 | * consent |
||
139 | * |
||
140 | * @var boolean |
||
141 | */ |
||
142 | protected $consent; |
||
143 | |||
144 | /** |
||
145 | * defaultValue |
||
146 | * |
||
147 | * @var string |
||
148 | */ |
||
149 | protected $defaultValue; |
||
150 | |||
151 | /** |
||
152 | * validation |
||
153 | * |
||
154 | * @var string |
||
155 | */ |
||
156 | protected $validation = ''; |
||
157 | |||
158 | /** |
||
159 | * max input length |
||
160 | * |
||
161 | * @var integer |
||
162 | */ |
||
163 | protected $maxInputLength = 0; |
||
164 | |||
165 | /** |
||
166 | * Embargo field option |
||
167 | * |
||
168 | * @var boolean |
||
169 | */ |
||
170 | protected $embargo; |
||
171 | |||
172 | /** |
||
173 | * fis mapping |
||
174 | * |
||
175 | * @var string |
||
176 | */ |
||
177 | protected $fisPersonMapping = ''; |
||
178 | |||
179 | /** |
||
180 | * fis mapping |
||
181 | * |
||
182 | * @var string |
||
183 | */ |
||
184 | protected $fisOrganisationMapping = ''; |
||
185 | |||
186 | /** |
||
187 | * gnd mapping |
||
188 | * |
||
189 | * @var string |
||
190 | */ |
||
191 | protected $gndPersonMapping = ''; |
||
192 | |||
193 | /** |
||
194 | * gnd mapping |
||
195 | * |
||
196 | * @var string |
||
197 | */ |
||
198 | protected $gndOrganisationMapping = ''; |
||
199 | |||
200 | /** |
||
201 | * ror mapping |
||
202 | * |
||
203 | * @var string |
||
204 | */ |
||
205 | protected $rorMapping = ''; |
||
206 | |||
207 | /** |
||
208 | * zdb mapping |
||
209 | * |
||
210 | * @var string |
||
211 | */ |
||
212 | protected $zdbMapping = ''; |
||
213 | |||
214 | /** |
||
215 | * unpaywall mapping |
||
216 | * @var string |
||
217 | */ |
||
218 | protected $unpaywallMapping = ''; |
||
219 | |||
220 | /** |
||
221 | * orcid person mapping |
||
222 | * @var string |
||
223 | */ |
||
224 | protected $orcidPersonMapping = ''; |
||
225 | |||
226 | /** |
||
227 | * help text |
||
228 | * |
||
229 | * @var string |
||
230 | */ |
||
231 | protected $helpText = ''; |
||
232 | |||
233 | /** |
||
234 | * Returns the name |
||
235 | * |
||
236 | * @return string $name |
||
237 | */ |
||
238 | public function getName() |
||
239 | { |
||
240 | return $this->name; |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * Sets the name |
||
245 | * |
||
246 | * @param string $name |
||
247 | * @return void |
||
248 | */ |
||
249 | public function setName($name) |
||
250 | { |
||
251 | $this->name = $name; |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * Returns the displayName |
||
256 | * |
||
257 | * @return string $displayName |
||
258 | */ |
||
259 | public function getDisplayName() |
||
260 | { |
||
261 | return $this->displayName; |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * Sets the displayName |
||
266 | * |
||
267 | * @param string $displayName |
||
268 | * @return void |
||
269 | */ |
||
270 | public function setDisplayName($displayName) |
||
271 | { |
||
272 | $this->displayName = $displayName; |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * Returns the maxIteration |
||
277 | * |
||
278 | * @return integer $maxIteration |
||
279 | */ |
||
280 | public function getMaxIteration() |
||
281 | { |
||
282 | return $this->maxIteration; |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Sets the maxIteration |
||
287 | * |
||
288 | * @param integer $maxIteration |
||
289 | * @return void |
||
290 | */ |
||
291 | public function setMaxIteration($maxIteration) |
||
292 | { |
||
293 | $this->maxIteration = $maxIteration; |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * Returns the mandatory |
||
298 | * |
||
299 | * @return string $mandatory |
||
300 | */ |
||
301 | public function getMandatory() |
||
302 | { |
||
303 | return $this->mandatory; |
||
304 | } |
||
305 | |||
306 | /** |
||
307 | * Sets the mandatory |
||
308 | * |
||
309 | * @param string $mandatory |
||
310 | * @return void |
||
311 | */ |
||
312 | public function setMandatory($mandatory) |
||
313 | { |
||
314 | $this->mandatory = $mandatory; |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * Returns the modsExtension |
||
319 | * |
||
320 | * @return boolean $modsExtension |
||
321 | */ |
||
322 | public function getModsExtension() |
||
323 | { |
||
324 | return $this->modsExtension; |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * Sets the modsExtension |
||
329 | * |
||
330 | * @param boolean $modsExtension |
||
331 | * @return void |
||
332 | */ |
||
333 | public function setModsExtension($modsExtension) |
||
334 | { |
||
335 | $this->modsExtension = boolval($modsExtension); |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * Returns the boolean state of modsExtension |
||
340 | * |
||
341 | * @return boolean |
||
342 | */ |
||
343 | public function isModsExtension() |
||
344 | { |
||
345 | return $this->modsExtension; |
||
346 | } |
||
347 | |||
348 | /** |
||
349 | * Returns the mapping |
||
350 | * |
||
351 | * @return string $mapping |
||
352 | */ |
||
353 | public function getMapping() |
||
354 | { |
||
355 | return $this->mapping; |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * Sets the mapping |
||
360 | * |
||
361 | * @param string $mapping |
||
362 | * @return void |
||
363 | */ |
||
364 | public function setMapping($mapping) |
||
365 | { |
||
366 | $this->mapping = $mapping; |
||
367 | } |
||
368 | |||
369 | /** |
||
370 | * Returns the relative mapping |
||
371 | * |
||
372 | * @return string $relativeMapping |
||
373 | */ |
||
374 | public function getRelativeMapping() |
||
375 | { |
||
376 | return trim($this->mapping, " /"); |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * Returns the inputField |
||
381 | * |
||
382 | * @return integer $inputField |
||
383 | */ |
||
384 | public function getInputField() |
||
385 | { |
||
386 | return $this->inputField; |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * Sets the inputField |
||
391 | * |
||
392 | * @param integer $inputField |
||
393 | * @return void |
||
394 | */ |
||
395 | public function setInputField($inputField) |
||
396 | { |
||
397 | $this->inputField = $inputField; |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * Returns always NULL because an Object never has children. |
||
402 | * |
||
403 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject |
||
404 | */ |
||
405 | public function getChildren() |
||
408 | } |
||
409 | |||
410 | /** |
||
411 | * Returns the inputOptionList |
||
412 | * |
||
413 | * @return \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList |
||
414 | */ |
||
415 | public function getInputOptionList() |
||
416 | { |
||
417 | return $this->inputOptionList; |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * Sets the inputOptionList |
||
422 | * |
||
423 | * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList |
||
424 | * @return void |
||
425 | */ |
||
426 | public function setInputOptionList(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList) |
||
429 | } |
||
430 | |||
431 | /** |
||
432 | * Returns the fillOutService |
||
433 | * |
||
434 | * @return string $fillOutService |
||
435 | */ |
||
436 | public function getFillOutService() |
||
437 | { |
||
438 | return $this->fillOutService; |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * Sets the fillOutService |
||
443 | * |
||
444 | * @param string $fillOutService |
||
445 | * @return void |
||
446 | */ |
||
447 | public function setFillOutService($fillOutService) |
||
448 | { |
||
449 | $this->fillOutService = $fillOutService; |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * Returns the accessRestrictionRoles |
||
454 | * |
||
455 | * @return array $accessRestrictionRoles |
||
456 | */ |
||
457 | public function getAccessRestrictionRoles() |
||
458 | { |
||
459 | if ($this->accessRestrictionRoles) { |
||
460 | return array_map('trim', explode(',', $this->accessRestrictionRoles)); |
||
461 | } else { |
||
462 | return array(); |
||
463 | } |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Sets the accessRestrictionRoles |
||
468 | * |
||
469 | * @param array $accessRestrictionRoles |
||
470 | * @return void |
||
471 | */ |
||
472 | public function setAccessRestrictionRoles($accessRestrictionRoles) |
||
473 | { |
||
474 | $this->accessRestrictionRoles = implode(',', $accessRestrictionRoles); |
||
475 | } |
||
476 | |||
477 | /** |
||
478 | * Returns the consent |
||
479 | * |
||
480 | * @return boolean $consent |
||
481 | */ |
||
482 | public function getConsent() |
||
483 | { |
||
484 | return $this->consent; |
||
485 | } |
||
486 | |||
487 | /** |
||
488 | * Sets the consent |
||
489 | * |
||
490 | * @param boolean $consent |
||
491 | * @return void |
||
492 | */ |
||
493 | public function setConsent($consent) |
||
494 | { |
||
495 | $this->consent = boolval($consent); |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * Returns the defaultValue |
||
500 | * |
||
501 | * @return string $defaultValue |
||
502 | */ |
||
503 | public function getDefaultValue() |
||
504 | { |
||
505 | return $this->defaultValue; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * Sets the defaultValue |
||
510 | * |
||
511 | * @param string $defaultValue |
||
512 | * @return void |
||
513 | */ |
||
514 | public function setDefaultValue($defaultValue) |
||
515 | { |
||
516 | $this->defaultValue = $defaultValue; |
||
517 | } |
||
518 | |||
519 | /** |
||
520 | * Returns the validation |
||
521 | * |
||
522 | * @return string $validation |
||
523 | */ |
||
524 | public function getValidation() |
||
525 | { |
||
526 | return $this->validation; |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * Sets the validation |
||
531 | * |
||
532 | * @param string $validation |
||
533 | * @return void |
||
534 | */ |
||
535 | public function setValidation($validation) |
||
536 | { |
||
537 | $this->validation = $validation; |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * Returns the dataType |
||
542 | * |
||
543 | * @return string $dataType |
||
544 | */ |
||
545 | public function getDataType() |
||
546 | { |
||
547 | return $this->dataType; |
||
548 | } |
||
549 | |||
550 | /** |
||
551 | * Sets the dataType |
||
552 | * |
||
553 | * @param string $dataType |
||
554 | * @return void |
||
555 | */ |
||
556 | public function setDataType($dataType) |
||
557 | { |
||
558 | $this->dataType = $dataType; |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * @return string |
||
563 | */ |
||
564 | public function getGndFieldUid() |
||
565 | { |
||
566 | return $this->gndFieldUid; |
||
567 | } |
||
568 | |||
569 | /** |
||
570 | * @param string $gndFieldUid |
||
571 | */ |
||
572 | public function setGndFieldUid($gndFieldUid) |
||
573 | { |
||
574 | $this->gndFieldUid = $gndFieldUid; |
||
575 | } |
||
576 | |||
577 | /** |
||
578 | * @return integer |
||
579 | */ |
||
580 | public function getMaxInputLength() |
||
581 | { |
||
582 | if ($this->maxInputLength == 0) { |
||
583 | if ($this->inputField == self::input) { |
||
584 | return 255; |
||
585 | } else { |
||
586 | return 2048; |
||
587 | } |
||
588 | } else { |
||
589 | return $this->maxInputLength; |
||
590 | } |
||
591 | } |
||
592 | |||
593 | /** |
||
594 | * @return integer |
||
595 | */ |
||
596 | public function setMaxInputLength($maxInputLength) |
||
597 | { |
||
598 | $this->maxInputLength = $maxInputLength; |
||
599 | } |
||
600 | |||
601 | /** |
||
602 | * @return bool |
||
603 | */ |
||
604 | public function getEmbargo(): bool |
||
605 | { |
||
606 | return $this->embargo; |
||
607 | } |
||
608 | |||
609 | /** |
||
610 | * @param bool $embargo |
||
611 | */ |
||
612 | public function setEmbargo(bool $embargo) |
||
613 | { |
||
614 | $this->embargo = boolval($embargo); |
||
615 | } |
||
616 | |||
617 | /** |
||
618 | * @return string |
||
619 | */ |
||
620 | public function getFisPersonMapping(): string |
||
621 | { |
||
622 | return $this->fisPersonMapping; |
||
623 | } |
||
624 | |||
625 | /** |
||
626 | * @param string $fisPersonMapping |
||
627 | */ |
||
628 | public function setFisPersonMapping(string $fisPersonMapping): void |
||
629 | { |
||
630 | $this->fisPersonMapping = $fisPersonMapping; |
||
631 | } |
||
632 | |||
633 | /** |
||
634 | * @return string |
||
635 | */ |
||
636 | public function getFisOrganisationMapping(): string |
||
637 | { |
||
638 | return $this->fisOrganisationMapping; |
||
639 | } |
||
640 | |||
641 | /** |
||
642 | * @param string $fisOrganisationMapping |
||
643 | */ |
||
644 | public function setFisOrganisationMapping(string $fisOrganisationMapping): void |
||
647 | } |
||
648 | |||
649 | /** |
||
650 | * @return string |
||
651 | */ |
||
652 | public function getRorMapping(): string |
||
653 | { |
||
654 | return $this->rorMapping; |
||
655 | } |
||
656 | |||
657 | /** |
||
658 | * @param string $rorMapping |
||
659 | */ |
||
660 | public function setRorMapping(string $rorMapping) |
||
661 | { |
||
662 | $this->rorMapping = $rorMapping; |
||
663 | } |
||
664 | |||
665 | /** |
||
666 | * @return string |
||
667 | */ |
||
668 | public function getZdbMapping(): string |
||
669 | { |
||
670 | return $this->zdbMapping; |
||
671 | } |
||
672 | |||
673 | /** |
||
674 | * @param string $zdbMapping |
||
675 | */ |
||
676 | public function setZdbMapping(string $zdbMapping): void |
||
677 | { |
||
678 | $this->zdbMapping = $zdbMapping; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * @return string |
||
683 | */ |
||
684 | public function getUnpaywallMapping(): string |
||
685 | { |
||
686 | return $this->unpaywallMapping; |
||
687 | } |
||
688 | |||
689 | /** |
||
690 | * @param string $unpaywallMapping |
||
691 | */ |
||
692 | public function setUnpaywallMapping(string $unpaywallMapping): void |
||
693 | { |
||
694 | $this->unpaywallMapping = $unpaywallMapping; |
||
695 | } |
||
696 | |||
697 | /** |
||
698 | * @return string |
||
699 | */ |
||
700 | public function getObjectType(): string |
||
701 | { |
||
702 | return $this->objectType; |
||
703 | } |
||
704 | /** |
||
705 | * Gets the jsonMapping |
||
706 | * |
||
707 | * @return string |
||
708 | */ |
||
709 | public function getJsonMapping(): string |
||
712 | } |
||
713 | |||
714 | /** |
||
715 | * Sets the jsonMapping |
||
716 | * |
||
717 | * @param string $jsonMapping |
||
718 | */ |
||
719 | public function setJsonMapping(string $jsonMapping): void |
||
720 | { |
||
721 | $this->jsonMapping = $jsonMapping; |
||
722 | } |
||
723 | /** |
||
724 | * @param string $objectType |
||
725 | */ |
||
726 | public function setObjectType(string $objectType): void |
||
727 | { |
||
728 | $this->objectType = $objectType; |
||
729 | } |
||
730 | |||
731 | /** |
||
732 | * @return string |
||
733 | */ |
||
734 | public function getGndPersonMapping(): string |
||
735 | { |
||
736 | return $this->gndPersonMapping; |
||
737 | } |
||
738 | |||
739 | /** |
||
740 | * @param string $gndPersonMapping |
||
741 | */ |
||
742 | public function setGndPersonMapping(string $gndPersonMapping): void |
||
743 | { |
||
744 | $this->gndPersonMapping = $gndPersonMapping; |
||
745 | } |
||
746 | |||
747 | /** |
||
748 | * @return string |
||
749 | */ |
||
750 | public function getGndOrganisationMapping(): string |
||
751 | { |
||
752 | return $this->gndOrganisationMapping; |
||
753 | } |
||
754 | |||
755 | /** |
||
756 | * @param string $gndOrganisationMapping |
||
757 | */ |
||
758 | public function setGndOrganisationMapping(string $gndOrganisationMapping): void |
||
759 | { |
||
760 | $this->gndOrganisationMapping = $gndOrganisationMapping; |
||
761 | } |
||
762 | |||
763 | /** |
||
764 | * @return string |
||
765 | */ |
||
766 | public function getOrcidPersonMapping(): string |
||
767 | { |
||
768 | return $this->orcidPersonMapping; |
||
769 | } |
||
770 | |||
771 | /** |
||
772 | * @param string $orcidPersonMapping |
||
773 | */ |
||
774 | public function setOrcidPersonMapping(string $orcidPersonMapping): void |
||
775 | { |
||
776 | $this->orcidPersonMapping = $orcidPersonMapping; |
||
777 | } |
||
778 | |||
779 | |||
780 | /** |
||
781 | * @return int |
||
782 | */ |
||
783 | public function getDepositLicense(): int |
||
784 | { |
||
785 | return $this->depositLicense; |
||
786 | } |
||
787 | |||
788 | /** |
||
789 | * @param int $depositLicense |
||
790 | */ |
||
791 | public function setDepositLicense($depositLicense): void |
||
794 | } |
||
795 | |||
796 | /** |
||
797 | * @return string |
||
798 | */ |
||
799 | public function getHelpText(): string |
||
800 | { |
||
801 | return $this->helpText; |
||
802 | } |
||
803 | |||
804 | /** |
||
805 | * @param string $helpText |
||
806 | */ |
||
807 | public function setHelpText(string $helpText): void |
||
810 | } |
||
811 | } |
||
812 |