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