We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 6 |
| Paths | 8 |
| Total Lines | 155 |
| Code Lines | 113 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 36 | public function mainAction() |
||
| 37 | { |
||
| 38 | // Quit without doing anything if required configuration variables are not set. |
||
| 39 | if (empty($this->settings['pages'])) { |
||
| 40 | $this->logger->warning('Incomplete plugin configuration'); |
||
|
1 ignored issue
–
show
|
|||
| 41 | } |
||
| 42 | |||
| 43 | // Check for selected collections. |
||
| 44 | if ($this->settings['collections']) { |
||
| 45 | // Include only selected collections. |
||
| 46 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 47 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 48 | |||
| 49 | $countTitles = $queryBuilder |
||
| 50 | ->count('tx_dlf_documents.uid') |
||
| 51 | ->from('tx_dlf_documents') |
||
| 52 | ->innerJoin( |
||
| 53 | 'tx_dlf_documents', |
||
| 54 | 'tx_dlf_relations', |
||
| 55 | 'tx_dlf_relations_joins', |
||
| 56 | $queryBuilder->expr()->eq( |
||
| 57 | 'tx_dlf_relations_joins.uid_local', |
||
| 58 | 'tx_dlf_documents.uid' |
||
| 59 | ) |
||
| 60 | ) |
||
| 61 | ->innerJoin( |
||
| 62 | 'tx_dlf_relations_joins', |
||
| 63 | 'tx_dlf_collections', |
||
| 64 | 'tx_dlf_collections_join', |
||
| 65 | $queryBuilder->expr()->eq( |
||
| 66 | 'tx_dlf_relations_joins.uid_foreign', |
||
| 67 | 'tx_dlf_collections_join.uid' |
||
| 68 | ) |
||
| 69 | ) |
||
| 70 | ->where( |
||
| 71 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), |
||
| 72 | $queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])), |
||
| 73 | $queryBuilder->expr()->eq('tx_dlf_documents.partof', 0), |
||
| 74 | $queryBuilder->expr()->in('tx_dlf_collections_join.uid', |
||
| 75 | $queryBuilder->createNamedParameter(GeneralUtility::intExplode(',', |
||
| 76 | $this->settings['collections']), Connection::PARAM_INT_ARRAY)), |
||
| 77 | $queryBuilder->expr()->eq('tx_dlf_relations_joins.ident', |
||
| 78 | $queryBuilder->createNamedParameter('docs_colls')) |
||
| 79 | ) |
||
| 80 | ->execute() |
||
| 81 | ->fetchColumn(0); |
||
| 82 | |||
| 83 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 84 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 85 | $subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 86 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 87 | |||
| 88 | $subQuery = $subQueryBuilder |
||
| 89 | ->select('tx_dlf_documents.partof') |
||
| 90 | ->from('tx_dlf_documents') |
||
| 91 | ->where( |
||
| 92 | $subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0) |
||
| 93 | ) |
||
| 94 | ->groupBy('tx_dlf_documents.partof') |
||
| 95 | ->getSQL(); |
||
| 96 | |||
| 97 | $countVolumes = $queryBuilder |
||
| 98 | ->count('tx_dlf_documents.uid') |
||
| 99 | ->from('tx_dlf_documents') |
||
| 100 | ->innerJoin( |
||
| 101 | 'tx_dlf_documents', |
||
| 102 | 'tx_dlf_relations', |
||
| 103 | 'tx_dlf_relations_joins', |
||
| 104 | $queryBuilder->expr()->eq( |
||
| 105 | 'tx_dlf_relations_joins.uid_local', |
||
| 106 | 'tx_dlf_documents.uid' |
||
| 107 | ) |
||
| 108 | ) |
||
| 109 | ->innerJoin( |
||
| 110 | 'tx_dlf_relations_joins', |
||
| 111 | 'tx_dlf_collections', |
||
| 112 | 'tx_dlf_collections_join', |
||
| 113 | $queryBuilder->expr()->eq( |
||
| 114 | 'tx_dlf_relations_joins.uid_foreign', |
||
| 115 | 'tx_dlf_collections_join.uid' |
||
| 116 | ) |
||
| 117 | ) |
||
| 118 | ->where( |
||
| 119 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), |
||
| 120 | $queryBuilder->expr()->eq('tx_dlf_collections_join.pid', intval($this->settings['pages'])), |
||
| 121 | $queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery), |
||
| 122 | $queryBuilder->expr()->in('tx_dlf_collections_join.uid', |
||
| 123 | $queryBuilder->createNamedParameter(GeneralUtility::intExplode(',', |
||
| 124 | $this->settings['collections']), Connection::PARAM_INT_ARRAY)), |
||
| 125 | $queryBuilder->expr()->eq('tx_dlf_relations_joins.ident', |
||
| 126 | $queryBuilder->createNamedParameter('docs_colls')) |
||
| 127 | ) |
||
| 128 | ->execute() |
||
| 129 | ->fetchColumn(0); |
||
| 130 | } else { |
||
| 131 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 132 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 133 | |||
| 134 | // Include all collections. |
||
| 135 | $countTitles = $queryBuilder |
||
| 136 | ->count('tx_dlf_documents.uid') |
||
| 137 | ->from('tx_dlf_documents') |
||
| 138 | ->where( |
||
| 139 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), |
||
| 140 | $queryBuilder->expr()->eq('tx_dlf_documents.partof', 0), |
||
| 141 | Helper::whereExpression('tx_dlf_documents') |
||
| 142 | ) |
||
| 143 | ->execute() |
||
| 144 | ->fetchColumn(0); |
||
| 145 | |||
| 146 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 147 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 148 | $subQueryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
||
| 149 | ->getQueryBuilderForTable('tx_dlf_documents'); |
||
| 150 | |||
| 151 | $subQuery = $subQueryBuilder |
||
| 152 | ->select('tx_dlf_documents.partof') |
||
| 153 | ->from('tx_dlf_documents') |
||
| 154 | ->where( |
||
| 155 | $subQueryBuilder->expr()->neq('tx_dlf_documents.partof', 0) |
||
| 156 | ) |
||
| 157 | ->groupBy('tx_dlf_documents.partof') |
||
| 158 | ->getSQL(); |
||
| 159 | |||
| 160 | $countVolumes = $queryBuilder |
||
| 161 | ->count('tx_dlf_documents.uid') |
||
| 162 | ->from('tx_dlf_documents') |
||
| 163 | ->where( |
||
| 164 | $queryBuilder->expr()->eq('tx_dlf_documents.pid', intval($this->settings['pages'])), |
||
| 165 | $queryBuilder->expr()->notIn('tx_dlf_documents.uid', $subQuery) |
||
| 166 | ) |
||
| 167 | ->execute() |
||
| 168 | ->fetchColumn(0); |
||
| 169 | } |
||
| 170 | |||
| 171 | // Set replacements. |
||
| 172 | $args['###TITLES###'] = $countTitles . ' ' . htmlspecialchars( |
||
| 173 | LocalizationUtility::translate( |
||
| 174 | ($countTitles > 1 ? 'titles' : 'title'), 'dlf' |
||
| 175 | ) |
||
| 176 | ); |
||
| 177 | |||
| 178 | $args['###VOLUMES###'] = $countVolumes . ' ' . htmlspecialchars( |
||
| 179 | LocalizationUtility::translate( |
||
| 180 | ($countTitles > 1 ? 'volumes' : 'volume'), 'dlf' |
||
| 181 | ) |
||
| 182 | ); |
||
| 183 | |||
| 184 | // Apply replacements. |
||
| 185 | $content = $this->settings['description']; |
||
| 186 | foreach ($args as $key => $value) { |
||
| 187 | $content = str_replace($key, $value, $content); |
||
| 188 | } |
||
| 189 | |||
| 190 | $this->view->assign('content', $content); |
||
| 191 | } |
||
| 193 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.