Conditions | 10 |
Paths | 8 |
Total Lines | 33 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
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 |
||
45 | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) { |
||
46 | if ($table === 'tt_content' && $status == 'update' && isset($fieldArray['pi_flexform'])) { |
||
47 | $checkFields = array( |
||
48 | 'sDEF' => array( |
||
49 | 'settings.imagesPerPage', |
||
50 | 'settings.numberOfPages' |
||
51 | ), |
||
52 | ); |
||
53 | |||
54 | $flexformData = GeneralUtility::xml2array($fieldArray['pi_flexform']); |
||
55 | |||
56 | foreach ($checkFields as $sheet => $fields) { |
||
57 | foreach ($fields as $field) { |
||
58 | if (isset($flexformData['data'][$sheet]['lDEF'][$field]['vDEF']) && |
||
59 | $flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '') { |
||
60 | unset($flexformData['data'][$sheet]['lDEF'][$field]); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | // If remaining sheet does not contain fields, then remove the sheet |
||
65 | if (isset($flexformData['data'][$sheet]['lDEF']) && $flexformData['data'][$sheet]['lDEF'] === array()) { |
||
66 | unset($flexformData['data'][$sheet]); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Get the flexform tools |
||
72 | * @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexFormTools |
||
73 | */ |
||
74 | $flexFormTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools'); |
||
75 | $fieldArray['pi_flexform'] = $flexFormTools->flexArray2Xml($flexformData, TRUE); |
||
76 | } |
||
77 | } |
||
78 | |||
79 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.