We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 17 |
| Paths | 794 |
| Total Lines | 112 |
| Code Lines | 76 |
| 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 |
||
| 167 | protected function showSingleCollection(\Kitodo\Dlf\Domain\Model\Collection $collection) |
||
| 168 | { |
||
| 169 | // access storagePid from TypoScript |
||
| 170 | $pageSettings = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); |
||
| 171 | $this->settings['pages'] = $pageSettings["plugin."]["tx_dlf."]["persistence."]["storagePid"]; |
||
| 172 | |||
| 173 | // Fetch corresponding document UIDs from Solr. |
||
| 174 | if ($collection->getIndexSearch() != '') { |
||
| 175 | $solr_query = '(' . $collection->getIndexSearch() . ')'; |
||
| 176 | } else { |
||
| 177 | $solr_query = 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '") AND toplevel:true'; |
||
| 178 | } |
||
| 179 | $solr = Solr::getInstance($this->settings['solrcore']); |
||
| 180 | if (!$solr->ready) { |
||
| 181 | $this->logger->error('Apache Solr not available'); |
||
| 182 | return; |
||
| 183 | } |
||
| 184 | $params['fields'] = 'uid'; |
||
| 185 | $params['sort'] = ['uid' => 'asc']; |
||
| 186 | $solrResult = $solr->search_raw($solr_query, $params); |
||
| 187 | // Initialize array |
||
| 188 | $documentSet = []; |
||
| 189 | foreach ($solrResult as $doc) { |
||
| 190 | if ($doc->uid) { |
||
| 191 | $documentSet[] = $doc->uid; |
||
| 192 | } |
||
| 193 | } |
||
| 194 | $documentSet = array_unique($documentSet); |
||
| 195 | |||
| 196 | $this->settings['documentSets'] = implode(',', $documentSet); |
||
| 197 | |||
| 198 | $documents = $this->documentRepository->findDocumentsBySettings($this->settings); |
||
| 199 | |||
| 200 | $toplevel = []; |
||
| 201 | $subparts = []; |
||
| 202 | $listMetadata = []; |
||
| 203 | // Process results. |
||
| 204 | /** @var Document $document */ |
||
| 205 | foreach ($documents as $document) { |
||
| 206 | if (empty($listMetadata)) { |
||
| 207 | $listMetadata = [ |
||
| 208 | 'label' => htmlspecialchars($collection->getLabel()), |
||
| 209 | 'description' => $collection->getDescription(), |
||
| 210 | 'thumbnail' => htmlspecialchars($collection->getThumbnail()), |
||
| 211 | 'options' => [ |
||
| 212 | 'source' => 'collection', |
||
| 213 | 'select' => $id, |
||
| 214 | 'userid' => $collection->getFeCruserId(), |
||
| 215 | 'params' => ['filterquery' => [['query' => 'collection_faceting:("' . $collection->getIndexName() . '")']]], |
||
| 216 | 'core' => '', |
||
| 217 | 'order' => 'title', |
||
| 218 | 'order.asc' => true |
||
| 219 | ] |
||
| 220 | ]; |
||
| 221 | } |
||
| 222 | // Prepare document's metadata for sorting. |
||
| 223 | $sorting = unserialize($document->getMetadataSorting()); |
||
| 224 | if (!empty($sorting['type']) && MathUtility::canBeInterpretedAsInteger($sorting['type'])) { |
||
| 225 | $sorting['type'] = Helper::getIndexNameFromUid($sorting['type'], 'tx_dlf_structures', $this->settings['pages']); |
||
| 226 | } |
||
| 227 | if (!empty($sorting['owner']) && MathUtility::canBeInterpretedAsInteger($sorting['owner'])) { |
||
| 228 | $sorting['owner'] = Helper::getIndexNameFromUid($sorting['owner'], 'tx_dlf_libraries', $this->settings['pages']); |
||
| 229 | } |
||
| 230 | if (!empty($sorting['collection']) && MathUtility::canBeInterpretedAsInteger($sorting['collection'])) { |
||
| 231 | $sorting['collection'] = Helper::getIndexNameFromUid($sorting['collection'], 'tx_dlf_collections', $this->settings['pages']); |
||
| 232 | } |
||
| 233 | // Split toplevel documents from volumes. |
||
| 234 | if ($document->getPartof() == 0) { |
||
| 235 | $toplevel[$document->getUid()] = [ |
||
| 236 | 'u' => $document->getUid(), |
||
| 237 | 'h' => '', |
||
| 238 | 's' => $sorting, |
||
| 239 | 'p' => [] |
||
| 240 | ]; |
||
| 241 | } else { |
||
| 242 | // volume_sorting should be always set - but it's not a required field. We append the uid to the array key to make it always unique. |
||
| 243 | $subparts[$document->getPartof()][$document->getVolumeSorting() . str_pad($document->getUid(), 9, '0', STR_PAD_LEFT)] = [ |
||
| 244 | 'u' => $document->getUid(), |
||
| 245 | 'h' => '', |
||
| 246 | 's' => $sorting, |
||
| 247 | 'p' => [] |
||
| 248 | ]; |
||
| 249 | } |
||
| 250 | } |
||
| 251 | |||
| 252 | // Add volumes to the corresponding toplevel documents. |
||
| 253 | foreach ($subparts as $partof => $parts) { |
||
| 254 | ksort($parts); |
||
| 255 | foreach ($parts as $part) { |
||
| 256 | if (!empty($toplevel[$partof])) { |
||
| 257 | $toplevel[$partof]['p'][] = ['u' => $part['u']]; |
||
| 258 | } else { |
||
| 259 | $toplevel[$part['u']] = $part; |
||
| 260 | } |
||
| 261 | } |
||
| 262 | } |
||
| 263 | // Save list of documents. |
||
| 264 | $list = GeneralUtility::makeInstance(DocumentList::class); |
||
| 265 | $list->reset(); |
||
| 266 | $list->add(array_values($toplevel)); |
||
| 267 | $listMetadata['options']['numberOfToplevelHits'] = count($list); |
||
| 268 | $list->metadata = $listMetadata; |
||
| 269 | $list->sort('title'); |
||
| 270 | $list->save(); |
||
| 271 | // Clean output buffer. |
||
| 272 | ob_end_clean(); |
||
| 273 | |||
| 274 | $uri = $this->uriBuilder |
||
| 275 | ->reset() |
||
| 276 | ->setTargetPageUid($this->settings['targetPid']) |
||
| 277 | ->uriFor('main', [], 'ListView', 'dlf', 'ListView'); |
||
| 278 | $this->redirectToURI($uri); |
||
| 279 | } |
||
| 281 |
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