Conditions | 10 |
Paths | 8 |
Total Lines | 53 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 2 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
43 | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) |
||
44 | { |
||
45 | if ($table === 'tt_content' && $status == 'update' && isset($fieldArray['pi_flexform'])) { |
||
46 | $checkFields = [ |
||
47 | 'notification' => [ |
||
48 | 'settings.notification.senderEmail', |
||
49 | 'settings.notification.senderName', |
||
50 | 'settings.notification.adminEmail', |
||
51 | 'settings.notification.registrationNew.userSubject', |
||
52 | 'settings.notification.registrationNew.adminSubject', |
||
53 | 'settings.notification.registrationConfirmed.userSubject', |
||
54 | 'settings.notification.registrationConfirmed.adminSubject', |
||
55 | 'settings.notification.registrationCancelled.userSubject', |
||
56 | 'settings.notification.registrationCancelled.adminSubject', |
||
57 | ], |
||
58 | 'sDEF' => [ |
||
59 | 'settings.templateLayout', |
||
60 | 'settings.detailPid', |
||
61 | 'settings.listPid', |
||
62 | 'settings.registrationPid', |
||
63 | 'settings.displayMode', |
||
64 | 'settings.orderField', |
||
65 | 'settings.orderDirection', |
||
66 | 'settings.topEventRestriction', |
||
67 | 'settings.queryLimit', |
||
68 | 'settings.category', |
||
69 | 'settings.restrictForeignRecordsToStoragePage', |
||
70 | 'settings.storagePage', |
||
71 | 'settings.registration.requiredFields' |
||
72 | ] |
||
73 | ]; |
||
74 | |||
75 | $flexformData = GeneralUtility::xml2array($fieldArray['pi_flexform']); |
||
76 | foreach ($checkFields as $sheet => $fields) { |
||
77 | foreach ($fields as $field) { |
||
78 | if (isset($flexformData['data'][$sheet]['lDEF'][$field]['vDEF']) && |
||
79 | $flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '' |
||
80 | ) { |
||
81 | unset($flexformData['data'][$sheet]['lDEF'][$field]); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | // If remaining sheet does not contain fields, then remove the sheet |
||
86 | if (isset($flexformData['data'][$sheet]['lDEF']) && $flexformData['data'][$sheet]['lDEF'] === []) { |
||
87 | unset($flexformData['data'][$sheet]); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | /** @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexFormTools */ |
||
92 | $flexFormTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools'); |
||
93 | $fieldArray['pi_flexform'] = $flexFormTools->flexArray2Xml($flexformData, true); |
||
94 | } |
||
95 | } |
||
96 | |||
98 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.