Conditions | 16 |
Paths | 57 |
Total Lines | 116 |
Code Lines | 46 |
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 |
||
209 | public function makeMenuArray($content, $conf) { |
||
210 | |||
211 | $this->init($conf); |
||
212 | |||
213 | // Load current document. |
||
214 | $this->loadDocument(); |
||
215 | |||
216 | if ($this->doc === NULL) { |
||
217 | |||
218 | // Quit without doing anything if required variables are not set. |
||
219 | return array (); |
||
220 | |||
221 | } else { |
||
222 | |||
223 | if (!empty($this->piVars['logicalPage'])) { |
||
224 | |||
225 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
226 | // The logical page parameter should not appear again |
||
227 | unset($this->piVars['logicalPage']); |
||
228 | |||
229 | } |
||
230 | |||
231 | // Set default values for page if not set. |
||
232 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
233 | if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { |
||
234 | |||
235 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
236 | |||
237 | } else { |
||
238 | |||
239 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
240 | |||
241 | } |
||
242 | |||
243 | $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
||
244 | |||
245 | } |
||
246 | |||
247 | $menuArray = array (); |
||
248 | |||
249 | // Does the document have physical elements or is it an external file? |
||
250 | if ($this->doc->physicalStructure || !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->doc->uid)) { |
||
251 | |||
252 | // Get all logical units the current page or track is a part of. |
||
253 | if (!empty($this->piVars['page']) && $this->doc->physicalStructure) { |
||
254 | |||
255 | $this->activeEntries = array_merge((array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[0]], (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->piVars['page']]]); |
||
256 | |||
257 | if (!empty($this->piVars['double']) && $this->piVars['page'] < $this->doc->numPages) { |
||
258 | |||
259 | $this->activeEntries = array_merge($this->activeEntries, (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->piVars['page'] + 1]]); |
||
260 | |||
261 | } |
||
262 | |||
263 | } |
||
264 | |||
265 | // Go through table of contents and create all menu entries. |
||
266 | foreach ($this->doc->tableOfContents as $entry) { |
||
267 | |||
268 | $menuArray[] = $this->getMenuEntry($entry, TRUE); |
||
269 | |||
270 | } |
||
271 | |||
272 | } else { |
||
273 | |||
274 | // Go through table of contents and create top-level menu entries. |
||
275 | foreach ($this->doc->tableOfContents as $entry) { |
||
276 | |||
277 | $menuArray[] = $this->getMenuEntry($entry, FALSE); |
||
278 | |||
279 | } |
||
280 | |||
281 | // Get all child documents from database. |
||
282 | $whereClause = 'tx_dlf_documents.partof='.intval($this->doc->uid).' AND tx_dlf_documents.structure=tx_dlf_structures.uid AND tx_dlf_structures.pid='.$this->doc->pid.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_structures'); |
||
283 | |||
284 | if ($this->conf['excludeOther']) { |
||
285 | |||
286 | $whereClause .= ' AND tx_dlf_documents.pid='.intval($this->conf['pages']); |
||
287 | |||
288 | } |
||
289 | |||
290 | // Build table of contents from database. |
||
291 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
292 | 'tx_dlf_documents.uid AS uid,tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_structures.index_name AS type', |
||
293 | 'tx_dlf_documents,tx_dlf_structures', |
||
294 | $whereClause, |
||
295 | '', |
||
296 | 'tx_dlf_documents.volume_sorting', |
||
297 | '' |
||
298 | ); |
||
299 | |||
300 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
301 | |||
302 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
303 | |||
304 | $menuArray[0]['_SUB_MENU'] = array (); |
||
305 | |||
306 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
||
307 | |||
308 | $entry = array ( |
||
309 | 'label' => $resArray['title'], |
||
310 | 'type' => $resArray['type'], |
||
311 | 'volume' => $resArray['volume'], |
||
312 | 'pagination' => '', |
||
313 | 'targetUid' => $resArray['uid'] |
||
314 | ); |
||
315 | |||
316 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, FALSE); |
||
317 | |||
318 | } |
||
319 | |||
320 | } |
||
321 | |||
322 | } |
||
323 | |||
324 | return $menuArray; |
||
325 | |||
329 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths