| Conditions | 10 |
| Paths | 13 |
| Total Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 84 | public function setIdsByGeneral(array $indexIds, array $indexTypes, array $additionalSlotArguments) |
||
| 85 | { |
||
| 86 | if (!\in_array($this->getUniqueRegisterKey(), $indexTypes, true)) { |
||
| 87 | return; |
||
| 88 | } |
||
| 89 | |||
| 90 | $table = 'sys_category_record_mm'; |
||
| 91 | $db = HelperUtility::getDatabaseConnection($table); |
||
| 92 | $q = $db->createQueryBuilder(); |
||
| 93 | |||
| 94 | $categoryIds = []; |
||
| 95 | if (isset($additionalSlotArguments['contentRecord']['uid']) && MathUtility::canBeInterpretedAsInteger($additionalSlotArguments['contentRecord']['uid'])) { |
||
| 96 | $rows = $q->select('uid_local') |
||
| 97 | ->from($table) |
||
| 98 | ->where( |
||
| 99 | $q->expr()->andX( |
||
| 100 | $q->expr()->eq('tablenames', $q->quote('tt_content')), |
||
| 101 | $q->expr()->eq('uid_foreign', $q->createNamedParameter($additionalSlotArguments['contentRecord']['uid'])) |
||
| 102 | ) |
||
| 103 | ) |
||
| 104 | ->execute() |
||
| 105 | ->fetchAll(); |
||
| 106 | |||
| 107 | foreach ($rows as $row) { |
||
| 108 | $categoryIds[] = (int) $row['uid_local']; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | if (isset($additionalSlotArguments['settings']['pluginConfiguration']) && $additionalSlotArguments['settings']['pluginConfiguration'] instanceof PluginConfiguration) { |
||
| 113 | /** @var PluginConfiguration $pluginConfiguration */ |
||
| 114 | $pluginConfiguration = $additionalSlotArguments['settings']['pluginConfiguration']; |
||
| 115 | $categories = $pluginConfiguration->getCategories(); |
||
| 116 | foreach ($categories as $category) { |
||
| 117 | $categoryIds[] = $category->getUid(); |
||
| 118 | } |
||
| 119 | } |
||
| 120 | |||
| 121 | if (empty($categoryIds)) { |
||
| 122 | return; |
||
| 123 | } |
||
| 124 | |||
| 125 | $q->resetQueryParts(); |
||
| 126 | $rows = $q->select('uid_foreign') |
||
| 127 | ->from('sys_category_record_mm') |
||
| 128 | ->where( |
||
| 129 | $q->expr()->in('uid_local', $categoryIds), |
||
| 130 | $q->expr()->eq('tablenames', $q->quote($this->getTableName())) |
||
| 131 | ) |
||
| 132 | ->execute() |
||
| 133 | ->fetchAll(); |
||
| 134 | |||
| 135 | foreach ($rows as $row) { |
||
| 136 | $indexIds[] = (int) $row['uid_foreign']; |
||
| 137 | } |
||
| 138 | |||
| 139 | return [ |
||
| 140 | 'indexIds' => $indexIds, |
||
| 141 | 'indexTypes' => $indexTypes, |
||
| 142 | 'additionalSlotArguments' => $additionalSlotArguments, |
||
| 143 | ]; |
||
| 144 | } |
||
| 145 | |||
| 174 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.