We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 5 |
| Paths | 9 |
| Total Lines | 85 |
| Code Lines | 67 |
| 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 |
||
| 37 | public function main($content, $conf) { |
||
| 38 | $this->init($conf); |
||
| 39 | // Turn cache on. |
||
| 40 | $this->setCache(TRUE); |
||
| 41 | // Quit without doing anything if required configuration variables are not set. |
||
| 42 | if (empty($this->conf['pages'])) { |
||
| 43 | Helper::devLog('Incomplete plugin configuration', DEVLOG_SEVERITY_WARNING); |
||
| 44 | return $content; |
||
| 45 | } |
||
| 46 | // Get description. |
||
| 47 | $content .= $this->pi_RTEcssText($this->conf['description']); |
||
| 48 | // Check for selected collections. |
||
| 49 | if ($this->conf['collections']) { |
||
| 50 | // Include only selected collections. |
||
| 51 | $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
||
| 52 | 'tx_dlf_documents.uid AS uid', |
||
| 53 | 'tx_dlf_documents', |
||
| 54 | 'tx_dlf_relations', |
||
| 55 | 'tx_dlf_collections', |
||
| 56 | 'AND tx_dlf_documents.pid='.intval($this->conf['pages']) |
||
| 57 | .' AND tx_dlf_collections.pid='.intval($this->conf['pages']) |
||
| 58 | .' AND tx_dlf_documents.partof=0' |
||
| 59 | .' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')' |
||
| 60 | .' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') |
||
| 61 | .Helper::whereClause('tx_dlf_documents') |
||
| 62 | .Helper::whereClause('tx_dlf_collections'), |
||
| 63 | 'tx_dlf_documents.uid', |
||
| 64 | '', |
||
| 65 | '' |
||
| 66 | ); |
||
| 67 | $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
||
| 68 | 'tx_dlf_documents.uid AS uid', |
||
| 69 | 'tx_dlf_documents', |
||
| 70 | 'tx_dlf_relations', |
||
| 71 | 'tx_dlf_collections', |
||
| 72 | 'AND tx_dlf_documents.pid='.intval($this->conf['pages']) |
||
| 73 | .' AND tx_dlf_collections.pid='.intval($this->conf['pages']) |
||
| 74 | .' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.Helper::whereClause('tx_dlf_documents').')' |
||
| 75 | .' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')' |
||
| 76 | .' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') |
||
| 77 | .Helper::whereClause('tx_dlf_documents') |
||
| 78 | .Helper::whereClause('tx_dlf_collections'), |
||
| 79 | 'tx_dlf_documents.uid', |
||
| 80 | '', |
||
| 81 | '' |
||
| 82 | ); |
||
| 83 | } else { |
||
| 84 | // Include all collections. |
||
| 85 | $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 86 | 'tx_dlf_documents.uid AS uid', |
||
| 87 | 'tx_dlf_documents', |
||
| 88 | 'tx_dlf_documents.pid='.intval($this->conf['pages']) |
||
| 89 | .' AND tx_dlf_documents.partof=0' |
||
| 90 | .Helper::whereClause('tx_dlf_documents'), |
||
| 91 | '', |
||
| 92 | '', |
||
| 93 | '' |
||
| 94 | ); |
||
| 95 | $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 96 | 'tx_dlf_documents.uid AS uid', |
||
| 97 | 'tx_dlf_documents', |
||
| 98 | 'tx_dlf_documents.pid='.intval($this->conf['pages']) |
||
| 99 | .' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.Helper::whereClause('tx_dlf_documents').')' |
||
| 100 | .Helper::whereClause('tx_dlf_documents'), |
||
| 101 | '', |
||
| 102 | '', |
||
| 103 | '' |
||
| 104 | ); |
||
| 105 | } |
||
| 106 | $countTitles = $GLOBALS['TYPO3_DB']->sql_num_rows($resultTitles); |
||
| 107 | $countVolumes = $GLOBALS['TYPO3_DB']->sql_num_rows($resultVolumes); |
||
| 108 | // Set replacements. |
||
| 109 | $replace = [ |
||
| 110 | 'key' => [ |
||
| 111 | '###TITLES###', |
||
| 112 | '###VOLUMES###' |
||
| 113 | ], |
||
| 114 | 'value' => [ |
||
| 115 | $countTitles.($countTitles > 1 ? $this->pi_getLL('titles', '', TRUE) : $this->pi_getLL('title', '', TRUE)), |
||
| 116 | $countVolumes.($countVolumes > 1 ? $this->pi_getLL('volumes', '', TRUE) : $this->pi_getLL('volume', '', TRUE)) |
||
| 117 | ] |
||
| 118 | ]; |
||
| 119 | // Apply replacements. |
||
| 120 | $content = str_replace($replace['key'], $replace['value'], $content); |
||
| 121 | return $this->pi_wrapInBaseClass($content); |
||
| 122 | } |
||
| 124 |