| Conditions | 14 |
| Paths | 9 |
| Total Lines | 97 |
| Code Lines | 74 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 60 | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$dataHandler): void |
||
|
|
|||
| 61 | { |
||
| 62 | if ($table === 'tt_content' && |
||
| 63 | $status === 'update' && |
||
| 64 | isset($fieldArray['pi_flexform']) && |
||
| 65 | $dataHandler->checkValue_currentRecord['CType'] === 'list' && |
||
| 66 | in_array( |
||
| 67 | $dataHandler->checkValue_currentRecord['list_type'], |
||
| 68 | [ |
||
| 69 | 'sfeventmgt_pieventlist', |
||
| 70 | 'sfeventmgt_pieventdetail', |
||
| 71 | 'sfeventmgt_pieventregistration', |
||
| 72 | 'sfeventmgt_pieventsearch', |
||
| 73 | 'sfeventmgt_pieventcalendar', |
||
| 74 | 'sfeventmgt_piuserreg', |
||
| 75 | 'sfeventmgt_pipayment', |
||
| 76 | ] |
||
| 77 | ) |
||
| 78 | ) { |
||
| 79 | $checkFields = [ |
||
| 80 | 'notification' => [ |
||
| 81 | 'settings.notification.senderEmail', |
||
| 82 | 'settings.notification.senderName', |
||
| 83 | 'settings.notification.adminEmail', |
||
| 84 | 'settings.notification.replyToEmail', |
||
| 85 | 'settings.notification.registrationNew.userSubject', |
||
| 86 | 'settings.notification.registrationWaitlistNew.userSubject', |
||
| 87 | 'settings.notification.registrationNew.adminSubject', |
||
| 88 | 'settings.notification.registrationWaitlistNew.adminSubject', |
||
| 89 | 'settings.notification.registrationConfirmed.userSubject', |
||
| 90 | 'settings.notification.registrationWaitlistConfirmed.userSubject', |
||
| 91 | 'settings.notification.registrationConfirmed.adminSubject', |
||
| 92 | 'settings.notification.registrationWaitlistConfirmed.adminSubject', |
||
| 93 | 'settings.notification.registrationCancelled.userSubject', |
||
| 94 | 'settings.notification.registrationCancelled.adminSubject', |
||
| 95 | 'settings.notification.registrationWaitlistMoveUp.userSubject', |
||
| 96 | 'settings.notification.registrationWaitlistMoveUp.adminSubject', |
||
| 97 | ], |
||
| 98 | 'sDEF' => [ |
||
| 99 | 'settings.displayMode', |
||
| 100 | 'settings.orderField', |
||
| 101 | 'settings.orderDirection', |
||
| 102 | 'settings.topEventRestriction', |
||
| 103 | 'settings.timeRestrictionLow', |
||
| 104 | 'settings.timeRestrictionHigh', |
||
| 105 | 'settings.includeCurrent', |
||
| 106 | 'settings.queryLimit', |
||
| 107 | 'settings.category', |
||
| 108 | 'settings.storagePage', |
||
| 109 | 'settings.registration.requiredFields', |
||
| 110 | 'settings.userRegistration.displayMode', |
||
| 111 | 'settings.userRegistration.orderField', |
||
| 112 | 'settings.userRegistration.orderDirection', |
||
| 113 | 'settings.userRegistration.storagePage', |
||
| 114 | 'settings.userRegistration.recursive', |
||
| 115 | 'settings.singleEvent', |
||
| 116 | ], |
||
| 117 | 'additional' => [ |
||
| 118 | 'settings.detailPid', |
||
| 119 | 'settings.listPid', |
||
| 120 | 'settings.registrationPid', |
||
| 121 | 'settings.paymentPid', |
||
| 122 | 'settings.restrictForeignRecordsToStoragePage', |
||
| 123 | ], |
||
| 124 | 'pagination' => [ |
||
| 125 | 'settings.pagination.enablePagination', |
||
| 126 | 'settings.pagination.itemsPerPage', |
||
| 127 | 'settings.pagination.maxNumPages', |
||
| 128 | ], |
||
| 129 | 'template' => [ |
||
| 130 | 'settings.templateLayout', |
||
| 131 | ], |
||
| 132 | ]; |
||
| 133 | |||
| 134 | $flexformData = GeneralUtility::xml2array($fieldArray['pi_flexform']); |
||
| 135 | if (!is_array($flexformData)) { |
||
| 136 | return; |
||
| 137 | } |
||
| 138 | |||
| 139 | foreach ($checkFields as $sheet => $fields) { |
||
| 140 | foreach ($fields as $field) { |
||
| 141 | if (isset($flexformData['data'][$sheet]['lDEF'][$field]['vDEF']) && |
||
| 142 | ($flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '' || |
||
| 143 | $flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '0') |
||
| 144 | ) { |
||
| 145 | unset($flexformData['data'][$sheet]['lDEF'][$field]); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | // If remaining sheet does not contain fields, then remove the sheet |
||
| 150 | if (isset($flexformData['data'][$sheet]['lDEF']) && $flexformData['data'][$sheet]['lDEF'] === []) { |
||
| 151 | unset($flexformData['data'][$sheet]); |
||
| 152 | } |
||
| 153 | } |
||
| 154 | |||
| 155 | $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class); |
||
| 156 | $fieldArray['pi_flexform'] = $flexFormTools->flexArray2Xml($flexformData, true); |
||
| 157 | } |
||
| 216 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.